cli: init
This commit is contained in:
18
cli.ts
Normal file
18
cli.ts
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
import { SpawnSyncOptionsWithBufferEncoding, SpawnSyncReturns, spawnSync as rawSpawnSync } from "child_process";
|
||||||
|
|
||||||
|
export function check(result: SpawnSyncReturns<Buffer | string>) {
|
||||||
|
if (result.error)
|
||||||
|
throw result.error;
|
||||||
|
if (result.status !== 0) {
|
||||||
|
throw result.stderr;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function checkedSpawnSync(
|
||||||
|
command: string,
|
||||||
|
args: readonly string[],
|
||||||
|
options: SpawnSyncOptionsWithBufferEncoding,
|
||||||
|
): SpawnSyncReturns<Buffer | string> {
|
||||||
|
return check(rawSpawnSync(command, args, options));
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user