How to use is-valid-glob - 2 common examples

To help you get started, we’ve selected a few is-valid-glob examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pixari / vue-i18n-extract / src / library / read-files.ts View on Github external
export function readLangFiles (src: string): SimpleFile[] {
  if (!isValidGlob(src)) {
    throw new Error('languageFiles isn\'\t a valid glob pattern.');
  }

  const targetFiles = glob.sync(src);

  if (targetFiles.length === 0) {
    throw new Error('languageFiles glob has no files.');
  }

  return targetFiles.map((f) => {
    const langPath = path.resolve(process.cwd(), f);

    const langModule = require(langPath);
    const { default: defaultImport } = langModule;

    const langObj = (defaultImport) ? defaultImport : langModule;
github pixari / vue-i18n-extract / src / library / read-files.ts View on Github external
export function readVueFiles (src: string): SimpleFile[] {
  if (!isValidGlob(src)) {
    throw new Error('vueFiles isn\'\t a valid glob pattern.');
  }

  const targetFiles = glob.sync(src);

  if (targetFiles.length === 0) {
    throw new Error('vueFiles glob has no files.');
  }

  return targetFiles.map((f) => {
    const fileName = f.replace(process.cwd(), '');
    return { fileName, path: f, content: fs.readFileSync(f, 'utf8') };
  });
}

is-valid-glob

Return true if a value is a valid glob pattern or patterns.

MIT
Latest version published 7 years ago

Package Health Score

71 / 100
Full package analysis

Popular is-valid-glob functions