, [opts]) ⇒ Promise

Runs a command.

This is an abstraction method that:

  1. Delegates to either node's native spawn or exec methods.
  2. Promisifies the calling of these function
  3. Handles stdout, stdin and stderr


Since: 3.0.0

Param Type Default Description
cmd Array The command to run as elements in an array.
[opts] Object Options to help determine how the exec is run.
[opts.mode] Boolean 'exec' The mode to run in
[opts.detached] Boolean false Whether we are running in detached mode or not (deprecated)
[opts.cwd] Boolean process.cwd() The directory to run the command from

Returns: Promise - A promise with collected results if applicable.

// Run a command in collect mode
return['ls', '-lsa', '/'], {mode: 'collect'})

// Catch and log any errors
.catch(err => {

// Print the collected results of the command
.then(results => {
}); ⇒ String \| null

Returns the path of a specific command or binary.

Since: 3.0.0

Param Type Description
cmd String A command to search for.

Returns: String | null - The path to the command or null.

// Determine the location of the 'docker' command
const which =;

results matching ""

    No results matching ""