How to use the fast-glob function in fast-glob

To help you get started, weā€™ve selected a few fast-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 somewhatabstract / checksync / src / get-files.js View on Github external
export default async function getFiles(
    includeGlobs: Array,
    excludeGlobs: Array,
    log: ILog,
): Promise> {
    const includePatterns = Array.from(turnIgnoresToGlobs(includeGlobs));
    log.verbose(
        () => `Include globs: ${JSON.stringify(includePatterns, null, "    ")}`,
    );
    const excludePatterns = Array.from(turnIgnoresToGlobs(excludeGlobs));
    log.verbose(
        () => `Exclude globs: ${JSON.stringify(excludePatterns, null, "    ")}`,
    );

    // Now let's match the patterns and see what files we get.
    const paths = await glob(includePatterns, {
        onlyFiles: true,
        absolute: true,
        ignore: excludePatterns,
    });
    const sortedPaths = paths.sort();
    log.verbose(
        () => `Discovered paths: ${JSON.stringify(sortedPaths, null, "    ")}`,
    );
    return sortedPaths;
}
github airbnb / lunar / scripts / tasks / generateIcon.ts View on Github external
export default withIcon('${compName}')(${compName});`,
        'utf8',
        error => {
          if (error) {
            reject(error);
          } else {
            console.log(`Generated ${compName}`);
            resolve();
          }
        },
      );
    });
  });
}

glob(filePattern, {
  absolute: true,
  cwd: SVG_ROOT,
})
  .then(svgPaths => Promise.all(svgPaths.map(svgPath => createIcon(svgPath))))
  .catch(error => {
    console.error(chalk.red(`Failed to generate icons: ${error.message}`));
    process.exitCode = 1;
  });
github doczjs / docz / core / docz-core / src / states / props.ts View on Github external
export const initial = (config: Config, pattern: string[]) => async (
  p: Params
) => {
  const { filterComponents } = config
  const cwd = paths.getRootDir(config)
  const files = await fastglob(pattern, { cwd, caseSensitiveMatch: false })
  const filtered = filterComponents ? filterComponents(files) : files
  const metadata = await docgen(filtered, config)
  p.setState('props', metadata)
}
github iamcco / vim-language-server / src / server / builtin.ts View on Github external
private async resolveColorschemes(runtimepath: string[]) {
    const list = runtimepath;
    if (config.vimruntime) {
      list.push(config.vimruntime);
    }
    const glob = runtimepath.map((p) => path.join(p.trim(), "colors/*.vim"));
    let colorschemes: string[] = [];
    try {
      colorschemes = await fg(glob, { onlyFiles: false, deep: 0 });
    } catch (error) {
      log.error(
        [
          `Index Colorschemes Error: ${JSON.stringify(glob)}`,
          `Error => ${error.stack || error.message || error}`,
        ].join("\n"),
      );
    }
    this.colorschemeItems = colorschemes.map((p) => {
      const label = path.basename(p, ".vim");
      const item: CompletionItem = {
        label,
        kind: CompletionItemKind.EnumMember,
        insertText: label,
        insertTextFormat: InsertTextFormat.PlainText,
      };
github shannonmoeller / ygor / packages / files / src / files.js View on Github external
export function find(pattern, options = {}) {
	const patterns = [].concat(pattern || []);
	const parent = globParent(patterns[0]);
	const cwd = path.resolve(process.cwd(), options.cwd || '');
	const workdir = `${path.resolve(cwd, parent)}/`;

	const globOptions = {
		absolute: true,
		...options,
		cwd,
	};

	let paths = glob(patterns, globOptions).then((x) =>
		x.map((y) => path.resolve(y))
	);

	if (options.sort !== false) {
		paths = paths.then((x) => x.sort());
	}

	return list(paths).map((x) =>
		file({
			cwd: workdir,
			path: x.replace(workdir, ''),
		})
	);
}
github airbnb / lunar / scripts / tasks / computeBuildSizes.ts View on Github external
async function computeBuildSizes() {
  const packages = await glob('./packages/*', { absolute: true, onlyDirectories: true });
  const stats: { name: string; sizes: object }[] = [];

  await Promise.all(
    packages.map(async packagePath => {
      const packageName = path.basename(packagePath);

      stats.push({
        name: packageName,
        sizes: {
          esm: await getTotalSize('./esm/**/*.js', packagePath),
          lib: await getTotalSize('./lib/**/*.js', packagePath),
        },
      });
    }),
  );
github vladimiry / ElectronMail / scripts / ava-loader.ts View on Github external
(async () => {
    const files = await fastGlob(
        sanitizeFastGlobPattern(filesGlobArgValue),
        {
            absolute: false,
            onlyFiles: true,
            stats: false,
        },
    );

    await execShell(["npx", ["ava", ...args, ...files]]);
})().catch((error) => {
    LOG(error);
github viewstools / morph / clean.js View on Github external
export default async function clean(src, verbose) {
  let morphed = await glob(
    [
      '**/*.view.js',
      `Fonts/*.js`,
      'useFlow.js',
      'useIsMedia.js',
      'useIsBefore.js',
      'useTools.js',
    ],
    {
      bashNative: ['linux'],
      cwd: src,
      ignore: ['*node_modules*'],
    }
  )

  await Promise.all(
github airbnb / lunar / scripts / tasks / computeBuildSizes.ts View on Github external
async function getTotalSize(fileGlob: string, cwd: string): Promise {
  const files = await glob(fileGlob, { absolute: true, cwd, onlyFiles: true });
  const sizes = await Promise.all(
    files.map(
      file =>
        new Promise((resolve, reject) => {
          fs.stat(file, (error, stats) => {
            if (error) {
              reject(error);
            } else {
              resolve(stats.size);
            }
          });
        }),
    ),
  );

  return sizes.reduce((sum, size) => sum + size, 0);
github tommy351 / kosko / packages / generate / src / generate.ts View on Github external
export async function generate(options: GenerateOptions): Promise {
  const extensions = (options.extensions || getExtensions()).join(",");
  const suffix = `?(.{${extensions}})`;
  const patterns = options.components.map(x => x + suffix);
  debug("Component patterns", patterns);

  const components = await glob(patterns, {
    cwd: options.path,
    onlyFiles: false
  });
  debug("Found components", components);

  const manifests: Manifest[] = [];

  for (const id of components) {
    const path = join(options.path, id);
    const mod = [].concat(await getComponentValue(path));

    for (let i = 0; i < mod.length; i++) {
      const data: any = mod[i];

      if (options.validate) {
        if (typeof data.validate === "function") {

fast-glob

It's a very fast and efficient glob library for Node.js

MIT
Latest version published 6 months ago

Package Health Score

88 / 100
Full package analysis