How to use the fast-glob.stream 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 sourcegraph / sourcegraph-typescript / src / server / resources.ts View on Github external
public async *glob(pattern: URL, { ignore = [] }: GlobOptions = {}): AsyncIterable {
        const files = glob.stream(fileURLToPath(pattern), {
            ignore,
            absolute: true,
            markDirectories: true,
            onlyFiles: false,
        })
        // tslint:disable-next-line: await-promise https://github.com/palantir/tslint/issues/3997
        for await (const file of files) {
            yield pathToFileURL(file as string)
        }
    }
github WordPress / gutenberg / bin / packages / build.js View on Github external
stream = new Readable( { encoding: 'utf8' } );
	files.forEach( ( file ) => stream.push( file ) );
	stream.push( null );
	stream = stream
		.pipe( createStyleEntryTransform() )
		.pipe( createBlockJsonEntryTransform() );
} else {
	const bar = new ProgressBar( 'Build Progress: [:bar] :percent', {
		width: 30,
		incomplete: ' ',
		total: 1,
	} );

	bar.tick( 0 );

	stream = glob.stream( [
		`${ PACKAGES_DIR }/*/src/**/*.js`,
		`${ PACKAGES_DIR }/*/src/*.scss`,
	], {
		ignore: [
			`**/test/**`,
			`**/__mocks__/**`,
		],
		onlyFiles: true,
	} );

	// Pause to avoid data flow which would begin on the `data` event binding,
	// but should wait until worker processing below.
	//
	// See: https://nodejs.org/api/stream.html#stream_two_reading_modes
	stream
		.pause()
github atomist / automation-client / lib / project / local / NodeFsLocalProject.ts View on Github external
const toFileTransform = new stream.Transform({ objectMode: true });

        toFileTransform._transform = function(chunk: any, encoding: string, done: (e?: any) => void): void {
            const f = new NodeFsLocalFile(baseDir, chunk);
            this.push(f);
            done();
        };

        const optsToUse: fg.Options = {
            // We can override these defaults...
            onlyFiles: true,
            ...opts,
            // ...but we force this one
            cwd: this.baseDir,
        };
        return fg.stream(globPatterns, optsToUse)
            .pipe(toFileTransform);
    }
github stoplightio / spectral / test-harness / codegen / index.ts View on Github external
(async () => {
  const stream = fg.stream('**/*.scenario', { cwd: SCENARIOS_ROOT });

  for await (const entry of stream) {
    const scenarioPath = join(SCENARIOS_ROOT, entry as string);
    const source = await fs.promises.readFile(scenarioPath, 'utf8');
    const scenario = parseScenarioFile(source);
    const assets = scenario.assets === void 0 ? [] : await writeAssets(entry as string, scenario.assets);

    const testFilename = `${basename(entry as string, true)}.test.ts`;
    const testRoot = await getDirectory(entry as string, TESTS_ROOT);

    const code = generate({
      assets,
      scenario,
      scenarioName: entry as string,
    });
github mrmlnc / fast-glob / src / benchmark / suites / regression / stream / fast-glob-previous.ts View on Github external
import * as fg from 'fast-glob';

import * as utils from '../../../utils';

const options: fg.Options = {
	cwd: path.join(process.cwd(), process.env.BENCHMARK_BASE_DIR as string),
	unique: false,
	...JSON.parse(process.env.BENCHMARK_OPTIONS as string)
};

const entries: string[] = [];

const timeStart = utils.timeStart();

const stream = fg.stream(process.env.BENCHMARK_PATTERN as string, options);

stream.once('error', () => process.exit(0));
stream.on('data', (entry: string) => entries.push(entry));
stream.once('end', () => {
	const memory = utils.getMemory();
	const time = utils.timeEnd(timeStart);
	const measures = utils.formatMeasures([...entries].length, time, memory);

	console.info(measures);
});
github sindresorhus / globby / index.js View on Github external
	return merge2(tasks.map(task => fastGlob.stream(task.pattern, task.options)))
		.pipe(filterStream)

fast-glob

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

MIT
Latest version published 5 months ago

Package Health Score

88 / 100
Full package analysis