Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async resolveCommandPath(command: string, options: SpawnOptions): Promise {
if (TERMINAL_INFO.windows) {
try {
return await this.which(command, { PATH: options.env && options.env.PATH ? options.env.PATH : process.env.PATH });
} catch (e) {
// ignore
}
}
return command;
}
}
export function spawn(command: string, args: readonly string[] = [], options?: SpawnOptions): ChildProcess {
return crossSpawn(command, [...args], options);
}
export function fork(modulePath: string, args: readonly string[] = [], options: ForkOptions & Pick = {}): ChildProcess {
return _fork(modulePath, [...args], options);
}
export interface WhichOptions {
PATH?: string;
PATHEXT?: string;
}
const DEFAULT_PATHEXT = TERMINAL_INFO.windows ? '.COM;.EXE;.BAT;.CMD' : undefined;
/**
* Find the first instance of a program in PATH.
*
* If `program` contains a path separator, this function will merely return it.
*
* @param program A command name, such as `ionic`
*/
export async function which(program: string, { PATH = process.env.PATH, PATHEXT = process.env.PATHEXT || DEFAULT_PATHEXT }: WhichOptions = {}): Promise {
if (program.includes(pathlib.sep)) {
return program;
}
const results = await _findExecutables(program, { PATH });
if (!results.length) {
export function createProcessEnv(...sources: { [key: string]: string | undefined; }[]): NodeJS.ProcessEnv {
return lodash.assign(TERMINAL_INFO.windows ? createCaseInsensitiveObject() : {}, ...sources);
}
export function emoji(x: string, fallback: string): string {
if (TERMINAL_INFO.windows) {
return fallback;
}
return x;
}