Wrapper around node spawn process to make it easier to use.
Command is converted to a promise.
const result = await exec("echo Hello World!");
console.log(result); // Hello World!
Spaces are trimmed.
const result = await exec("echo Hello World!");
console.log(result); // Hello World!
Quotes and double quotes can be used to don't trim spaces.
const result = await exec("echo 'Hello World!'");
console.log(result); // Hello World!
Other arguments are take literally.
const result = await exec("echo", "Hello World!");
console.log(result); // Hello World!
You can use array of strings to make it easier to read.
await exec("program", { env: {} }, [
["--option", "value"],
["--option", "value"],
["--option", "value"],
]);
-
printCommand
: Print command before running it. -
inherit
: Send output directly to the terminal. Some programs will work on "CI" mode if terminal's stdio is not inherited. -
spinner
: Display a spinner while the command is running. -
spawnOptions
: Override options sent to spawn. -
proxy
: Set proxy environment variables to this value. -
retries
: Retry running command on error. -
timeout
: Fail command on timeout. -
ignoreError
: Never rejects returning promise. -
stdin
: Send text like the charactery
to the program. -
printOutput
: When not inheriting stdio, send output from the program to the terminal.