How to use globby - 10 common examples

To help you get started, we’ve selected a few globby 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 DevExpress / testcafe / src / utils / parse-file-list.js View on Github external
async function execFileGlobs (globs, baseDir) {
    // NOTE: We have to create glob tasks, execute them and sort their results separately to preserve the same item order
    // as in the older globby versions (<7.1.1)
    const tasks = globby.generateGlobTasks(globs, { cwd: baseDir, expandDirectories: false, onlyFiles: true });
    const files = await Promise.all(tasks.map(getFiles));

    return flatten(files);
}
github Akryum / nodepack / packages / @nodepack / plugin-typescript / src / lib / tslint.js View on Github external
)
  }

  const files = args._ && args._.length
    ? args._
    : ['src/**/*.ts', 'src/**/*.tsx', 'tests/**/*.ts', 'tests/**/*.tsx']

  // respect linterOptions.exclude from tslint.json
  if (config && config.linterOptions && config.linterOptions.exclude) {
    // use the raw tslint.json data because config contains absolute paths
    const rawTslintConfig = JSON.parse(fs.readFileSync(tslintConfigPath, 'utf-8'))
    const excludedGlobs = rawTslintConfig.linterOptions.exclude
    excludedGlobs.forEach((g) => files.push('!' + g))
  }

  return globby(files, { cwd }).then(files => {
    files.forEach(lint)
    if (silent) return
    const result = linter.getResult()
    if (!result) {
      console.log(`No result.\n`)
    } else if (result.output.trim()) {
      process.stdout.write(result.output)
    } else if (result.fixes && result.fixes.length) {
      // some formatters do not report fixes.
      const f = new tslint.Formatters.ProseFormatter()
      process.stdout.write(f.format(result.failures, result.fixes))
    } else if (!result.failures.length) {
      console.log(`No lint errors found.\n`)
    }

    if (result.failures.length && !args.force) {
github elm-tooling / elm-language-server / src / elmWorkspace.ts View on Github external
private findElmFilesInFolder(element: [string, boolean]): IFolder[] {
    // Cleanup the path on windows, as globby does not like backslashes
    const globUri = element[0].replace(/\\/g, "/");

    return globby
      .sync(`${globUri}/**/*.elm`, { suppressErrors: true })
      .map(matchingPath => ({ path: matchingPath, writable: element[1] }));
  }
github gajus / canonical / src / utilities / bin / getTargetPaths.js View on Github external
paths = _.filter(paths, (pathName) => {
        const exclude = _.endsWith(pathName, '/') === true;

        if (exclude) {
            appendPaths.push(pathName + '**/*.js');
            appendPaths.push(pathName + '**/*.css');
            appendPaths.push(pathName + '**/*.scss');
        }

        return !exclude;
    });

    paths = paths.concat(appendPaths);
    paths = _.uniq(paths);

    paths = glob.sync(paths);
    // @todo Test whether glob.sync can return non-unique file paths.
    // paths = _.unique(paths);

    paths = _.map(paths, resolveAbsolutePath);

    return paths;
};
github angular / angular / aio / tools / stackblitz-builder / builder.js View on Github external
'!**/wallaby.js',
      '!**/karma-test-shim.js',
      '!**/karma.conf.js',
      '!**/test.ts',
      '!**/tsconfig.app.json',
      '!**/*stackblitz.*'
    ];

    // exclude all specs if no spec is mentioned in `files[]`
    if (!includeSpec) {
      defaultExcludes.push('!**/*.spec.*','!**/spec.js');
    }

    gpaths.push(...defaultExcludes);

    config.fileNames = globby.sync(gpaths, { ignore: ["**/node_modules/**"] });

    return config;
  }
}
github elastic / kibana / src / optimize / watch / watch_cache.ts View on Github external
public async reset() {
    this.logWithMetadata(['info', 'optimize:watch_cache'], 'The optimizer watch cache will reset');

    // start by deleting the state file to lower the
    // amount of time that another process might be able to
    // successfully read it once we decide to delete it
    await del(this.statePath, { force: true });

    // delete everything in optimize/.cache directory
    await del(await globby([normalizePosixPath(this.cachePath)], { dot: true }));

    // delete some empty folder that could be left
    // from the previous cache path reset action
    await deleteEmpty(this.cachePath);

    // delete dlls
    await del(this.dllsPath);

    // re-write new cache state file
    await this.write();

    this.logWithMetadata(['info', 'optimize:watch_cache'], 'The optimizer watch cache has reset');
  }
github GitbookIO / bipbip / src / bin.js View on Github external
async function main() {
    const inputFiles = program.args.length == 0 ? DEFAULT_FILES : program.args;
    const paths = await globby([...inputFiles, ...IGNORED_FILES]);

    paths.forEach(filePath => {
        // $FlowFixMe: flow doesn't accept dynamic require
        require(path.resolve(process.cwd(), filePath));
    });

    // Get all suites to run
    const input = getBenchmark();
    const previous = program.compare
        ? await loadResult(path.resolve(process.cwd(), program.compare))
        : null;

    const reporter = new BackgroundReporter();

    // Setup options for scenarios
    const options = {
github JS-DevTools / globify / lib / parsed-args.js View on Github external
function parseGlobs (args, parsed) {
  let patterns = [];

  if (parsed.globIndex === -1 && globby.hasMagic(args[0])) {
    while (args[0] && args[0][0] !== "-") {
      // We found an entry file glob pattern
      let pattern = args.shift();
      patterns.push(pattern);

      // Set the baseDir, if not already set
      parsed.baseDir = parsed.baseDir || helpers.getBaseDir(pattern);
    }

    if (patterns.length) {
      // We found entry file(s), so set the glob index and create the glob function
      parsed.globIndex = parsed.args.length;
      parsed.args.push((options) => {
        return globby.sync(patterns, options);
      });
    }
github JS-DevTools / version-bump-prompt / src / normalize-options.ts View on Github external
async function strictGlobMatch(file: string, options: object): Promise {
  let matches = await globby(file, options);

  if (matches.length === 0) {
    if (hasMagic(file)) {
      throw new Error(`Could not find any files matching "${file}".`);
    }
    else {
      throw new Error(`Could not find file: ${file}.`);
    }
  }

  // Return files in a predictable order
  return matches.sort();
}
github clippedjs / clipped / plugins / rollup / clipped.config.js View on Github external
cfg.plugins.use('autoinstall', require('@rollup/plugin-auto-install'), [{}])
      }

      // if (['umd', 'iife'].includes(cfg.output.format)) {
        cfg.plugins
          .use('node-resolve', require('rollup-plugin-node-resolve'), [{
            main: false,
            module: true,
            jsnext: true,
            extensions: ['.js', '.json'],
            preferBuiltIns: true,
            browser: true
          }])
      // }

      if (globby.hasMagic(cfg.input)) {
        cfg.plugins.use('multi-entry', require('rollup-plugin-multi-entry'), [])
      }
    }
  },

globby

User-friendly glob matching

MIT
Latest version published 4 months ago

Package Health Score

87 / 100
Full package analysis