mirror of
https://github.com/akveo/ngx-admin.git
synced 2025-12-16 15:40:11 +01:00
* fix(app):redirect after 404 * fix(app):docs building script * fix(app):add gulpfile for docs * fix(app): directory splitting * fix(app): build docs script * fix(app): build docs script * fix(app): build docs script * fix(app): relative path for scss * fix(app): relative path for scss * fix(app): relative path for scss * fix(app):fix footer icons * fix(app):fix footer icons * fix(app):fix footer icons * fix(app):config * fix(app):remove small-social * fix(docs): footer icons style * fix(docs): material page index file * fix(docs): descriptions and keyword * fix(docs): og description * fix(docs): og description and title * fix(docs): dem,o branch url * fix(docs): dynamic title for docs page * fix(docs): remove unused script * fix(docs): static title Co-authored-by: Evgeny Lupanov <e.lupanov@akveo.com>
37 lines
1,022 B
TypeScript
37 lines
1,022 B
TypeScript
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);
|
|
}
|
|
}
|