@bconnorwhite/exec

Execute commands while keeping flags easily configurable as an object.
yarn add @bconnorwhite/exec
- Run one or multiple commands
- Easily define arguments and flags
- Run commands in parallel or series
- Automatically pass through output by setting
stdio: "inherit"
API
exec
Types
exec(
command: string,
args?: string | string[],
flags?: Flags,
parallel = false
) => ChildProcess | SpawnSyncReturns<Buffer>
type Flags = {
[flag: string]: string | boolean;
}
Usage
import exec from "@bconnorwhite/exec";
exec("babel", ["./src"], {
"out-dir": "./build",
"config-file": "./babel.config.json",
"watch": true
});
execAll
Types
execAll(
commands: Command[],
options: Options
) => Promise<(ChildProcess | SpawnSyncReturns<Buffer>)[]>
type Command = {
command: string;
args?: string | string[];
flags?: Flags;
}
type Options = {
parallel?: boolean;
}
Usage
import { execAll } from "@bconnorwhite/exec";
execAll([{
command: "babel",
args: ["./src"],
flags: {
"out-dir": "./build",
"config-file": "./babel.config.json",
"watch": true
}
}, {
command: "tsc",
flags: {
"emitDeclarationOnly": true
}
}], {
parallel: false
});
flagsToArray
Types
flagsToArray(flags?: Flags) => string[]
type Flags = {
[flag: string]: string | boolean;
}
Usage
import { flagsToArray } from "@bconnorwhite/exec";
flagsToArray({
"out-dir": "./build",
"config-file": "./babel.config.json",
"watch": true
});