13 lines
385 B
TypeScript
13 lines
385 B
TypeScript
|
|
import { spawnSync } from 'node:child_process';
|
||
|
|
|
||
|
|
export function run(command: string, args: string[], cwd = process.cwd()) {
|
||
|
|
const result = spawnSync(command, args, {
|
||
|
|
cwd,
|
||
|
|
stdio: 'inherit',
|
||
|
|
shell: process.platform === 'win32',
|
||
|
|
});
|
||
|
|
|
||
|
|
if (result.error) throw result.error;
|
||
|
|
if (result.status !== 0) throw new Error(`Command failed: ${[command, ...args].join(' ')}`);
|
||
|
|
}
|