Home Manual Reference Source Test
import ExternalCommand from 'atscm-cli/src/lib/util/ExternalCommand.js'
public class | source

ExternalCommand

A static class providing utilities to run external commands.

Test:

Static Method Summary

Static Public Methods
public static

Resolves the executable path for the given command.

public static

run(name: string, args: string[], options: Object): Promise<string, Error>

Resolves the executable for the given command and runs it with the arguments and options given.

public static

spawn(bin: string, args: string[], options: Object): Promise<string, Error>

Spawns an executable with the given args and options.

Static Public Methods

public static resolveBin(name: string): Promise<string, Error> source

Resolves the executable path for the given command.

Params:

NameTypeAttributeDescription
name string

The command to resolve.

Return:

Promise<string, Error>

Fulfilled with the executable path or the error that occured while running which.

public static run(name: string, args: string[], options: Object): Promise<string, Error> source

Resolves the executable for the given command and runs it with the arguments and options given. See the node docs on the child_process module for all available spawn options.

Params:

NameTypeAttributeDescription
name string

The command to run.

args string[]
  • optional

The arguments to use.

options Object
  • optional

The options to use.

options.spawn Object
  • optional

Options to use for the spawned process.

options.onspawn function(process: node.ChildProcess)
  • optional

Callback to call once the process was created. Useful for handling stdio events etc.

Return:

Promise<string, Error>

Fulfilled with the child process' stdout or rejected with a spawn error, a non-zero exit code or an error that occured while running which.

See:

public static spawn(bin: string, args: string[], options: Object): Promise<string, Error> source

Spawns an executable with the given args and options. See the node docs on the child_process module for all available spawn options.

Params:

NameTypeAttributeDescription
bin string

Path to the executable to run.

args string[]
  • optional
  • default: []

The arguments to use.

options Object
  • optional

The options to use.

options.spawn Object
  • optional

Options to use for the spawned process.

options.onspawn function(process: node.ChildProcess)
  • optional

Callback to call once the process was created. Useful for handling stdio events etc.

Return:

Promise<string, Error>

Fulfilled with the child process' stdout or rejected with a spawn error or non-zero exit code.

See: