Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function _findExecutables(program: string, { PATH = process.env.PATH, PATHEXT = process.env.PATHEXT || DEFAULT_PATHEXT }: WhichOptions = {}): Promise {
const pathParts = getPathParts(PATH);
let programNames: string[];
// if windows, cycle through all possible executable extensions
// ex: node.exe, npm.cmd, etc.
if (TERMINAL_INFO.windows) {
const exts = getPathParts(PATHEXT).map(ext => ext.toLowerCase());
// don't append extensions if one has already been provided
programNames = exts.includes(pathlib.extname(program).toLowerCase()) ? [program] : exts.map(ext => program + ext);
} else {
programNames = [program];
}
return ([] as string[]).concat(...await map(programNames, async (programName): Promise =>
concurrentFilter(pathParts.map(p => pathlib.join(p, programName)), async p => isExecutableFile(p))));
}
private async getFilesAndSizesAndHashesForGlobPattern(buildDir: string): Promise {
const contents = await readdirp(buildDir, { filter: item => !/(css|js)\.map$/.test(item.path) });
const stats = await map(contents, async (f): Promise<[string, fs.Stats]> => [f, await stat(f)]);
const files = stats.filter(([ , s ]) => !s.isDirectory());
const items = await Promise.all(files.map(([f, s]) => this.getFileAndSizeAndHashForFile(buildDir, f, s)));
return items.filter(item => item.href !== 'pro-manifest.json');
}