2
0
mirror of https://github.com/iconify/iconify.git synced 2024-12-13 22:18:24 +00:00
iconify/packages/library-builder/src/exec.ts

26 lines
396 B
TypeScript
Raw Normal View History

import { spawn } from 'child_process';
/**
* Execute command
*/
export function exec(
dir: string,
cmd: string,
params: string[]
): Promise<number> {
return new Promise((fulfill, reject) => {
const result = spawn(cmd, params, {
cwd: dir,
stdio: 'inherit',
});
result.on('close', (code) => {
if (code !== 0) {
reject(code);
} else {
fulfill(0);
}
});
});
}