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 execAndLog(executable: string, args?: string[], options?: RunOptions): Promise {
const command: Command = {
executable,
args,
};
console.log(`\n\nRunning ${commandToString(command)}`);
const result: RunResult = await run(command, undefined, {
...options,
log: console.log,
showCommand: true,
showResult: true,
});
console.log(`\nResult of "${commandToString(command)}" [Exit code: ${result.exitCode}]:\n` + result.stdout + "\n");
if (result.exitCode) {
console.error(`Error while running "${commandToString(command)}": ${result.error}`);
throw new Error(result.stderr);
}
return Promise.resolve(result);
}
async function execAndLog(executable: string, args?: string[], options?: RunOptions): Promise {
const command: Command = {
executable,
args,
};
console.log(`\n\nRunning ${commandToString(command)}`);
const result: RunResult = await run(command, undefined, {
...options,
log: console.log,
showCommand: true,
showResult: true,
});
console.log(`\Result of "${commandToString(command)}" [Exit code: ${result.exitCode}]:\n` + result.stdout + "\n");
if (result.exitCode) {
console.error(`Error while running "${commandToString(command)}": ${result.error}`);
throw new Error(result.stderr);
}
return Promise.resolve(result);
args,
};
console.log(`\n\nRunning ${commandToString(command)}`);
const result: RunResult = await run(command, undefined, {
...options,
log: console.log,
showCommand: true,
showResult: true,
});
console.log(`\nResult of "${commandToString(command)}" [Exit code: ${result.exitCode}]:\n` + result.stdout + "\n");
if (result.exitCode) {
console.error(`Error while running "${commandToString(command)}": ${result.error}`);
throw new Error(result.stderr);
}
return Promise.resolve(result);
}
args,
};
console.log(`\n\nRunning ${commandToString(command)}`);
const result: RunResult = await run(command, undefined, {
...options,
log: console.log,
showCommand: true,
showResult: true,
});
console.log(`\Result of "${commandToString(command)}" [Exit code: ${result.exitCode}]:\n` + result.stdout + "\n");
if (result.exitCode) {
console.error(`Error while running "${commandToString(command)}": ${result.error}`);
throw new Error(result.stderr);
}
return Promise.resolve(result);
}