feat: update npm packages

This commit is contained in:
Sergey Andrievskiy 2021-08-06 18:48:35 +03:00 committed by d.strigo
parent f6d9ec88ad
commit 7a22737611
321 changed files with 19716 additions and 84 deletions

View file

@ -0,0 +1,37 @@
import { exec } from 'child_process';
import { promisify } from 'util';
export interface RunCommandOptions {
cwd?: string;
showLog?: boolean;
}
const DEFAULT_OPTIONS: RunCommandOptions = { cwd: process.cwd(), showLog: false };
export async function runCommand(command: string, options?: RunCommandOptions) {
let { cwd, showLog } = Object.assign({}, DEFAULT_OPTIONS, options);
try {
console.log(`Running "${command}" in "${cwd}"`);
const { stdout, stderr } = await promisify(exec)(command, { cwd });
if (showLog && stdout) {
console.log(stdout);
}
if (stderr) {
console.log(`stderr from "${command}" in "${cwd}"`);
console.warn(stderr);
}
} catch ({ message, stdout, stderr }) {
let errorMessage = `Error running "${command}" in "${cwd}": ${message}.`;
if (stdout) {
errorMessage += `\nstdout: ${stdout}`;
console.error(stdout);
}
if (stderr) {
errorMessage += `\nstderr: ${stderr}`;
}
throw new Error(errorMessage);
}
}