Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)
}
}
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()
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);
}
(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,
});
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);
});
return merge2(tasks.map(task => fastGlob.stream(task.pattern, task.options)))
.pipe(filterStream)