Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "util/child_process"

Index

Functions

childProcessString

  • childProcessString(cmd: string, args?: string[], opts?: SpawnOptions): string
  • Convert child process into an informative string.

    Parameters

    • cmd: string

      Command being run.

    • Default value args: string[] = []

      Arguments to command.

    • Default value opts: SpawnOptions = {}

      Standard child_process.SpawnOptions.

    Returns string

clearTimer

  • clearTimer(timer: Timer | undefined): undefined
  • Safely clear a timer that may be undefined.

    Parameters

    • timer: Timer | undefined

      A timer that may not be set.

    Returns undefined

execPromise

  • execPromise(cmd: string, args?: string[], opts?: SpawnSyncOptions): Promise<ExecPromiseResult>
  • Run a child process using cross-spawn, capturing and returning stdout and stderr, like exec, in a promise. If an error occurs, the process is killed by a signal, or the process exits with a non-zero status, the Promise is rejected. Any provided stdio option is ignored, being overwritten with ["pipe","pipe","pipe"]. Like with child_process.exec, this is not a good choice if the command produces a large amount of data on stdout or stderr.

    Parameters

    • cmd: string

      name of command, can be a shell script or MS Windows .bat or .cmd

    • Default value args: string[] = []

      command arguments

    • Default value opts: SpawnSyncOptions = {}

      standard child_process.SpawnOptions

    Returns Promise<ExecPromiseResult>

    Promise resolving to exec-like callback arguments having stdout and stderr properties. If an error occurs, exits with a non-zero status, and killed with a signal, the Promise is rejected with an ExecPromiseError.

killProcess

  • killProcess(pid: number, signal?: string | number): void
  • Cross-platform kill a process and all its children using tree-kill. On win32, signal is ignored since win32 does not support different signals.

    Parameters

    • pid: number

      ID of process to kill.

    • Optional signal: string | number

      optional signal name or number, Node.js default is used if not provided

    Returns void

spawnPromise

  • Call cross-spawn and return a Promise of its result. The result has the same shape as the object returned by child_process.spawnSync(), which means errors are not thrown but returned in the error property of the returned object. If your command will produce lots of output, provide a log to write it to.

    Parameters

    • cmd: string

      Command to run. If it is just an executable name, paths with be searched, batch and command files will be checked, etc. See cross-spawn documentation for details.

    • Default value args: string[] = []

      Arguments to command.

    • Default value opts: SpawnPromiseOptions = {}

      Standard child_process.SpawnOptions plus a few specific to this implementation.

    Returns Promise<SpawnPromiseReturns>

    a Promise that provides information on the child process and its execution result. If an error occurs, the error property of SpawnPromiseReturns will be populated.

Generated using TypeDoc