Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "lib/api-helper/misc/child_process"

Index

Type aliases

ErrorFinder

ErrorFinder: function

Type that can react to the exit of a spawned child process, after Node has terminated without reporting an error. This is necessary only for commands that can return a zero exit status on failure or non-zero exit code on success. Implementations should return true if an error is found, false otherwise.

Type declaration

    • (code: number, signal: string, log: WritableLog): boolean
    • Parameters

      • code: number
      • signal: string
      • log: WritableLog

      Returns boolean

SpawnAndLogOptions

SpawnAndLogOptions: SpawnPromiseOptions & object
deprecated

use SpawnLogOptions and spawnLog

Functions

Const SuccessIsReturn0ErrorFinder

  • SuccessIsReturn0ErrorFinder(code: number): boolean
  • Default ErrorFinder that regards everything but a return code of 0 as failure.

    Parameters

    • code: number

      process exit status

    Returns boolean

    true if exit status is not zero

clearTimers

  • clearTimers(...timers: Timer[]): void
  • Clear provided timers, checking to make sure the timers are defined before clearing them.

    Parameters

    • Rest ...timers: Timer[]

      the timers to clear.

    Returns void

killAndWait

  • killAndWait(childProcess: ChildProcess, wait?: number): Promise<void>
  • Kill the process and wait for it to shut down. This can take a while as processes may have shut down hooks. On win32, the process is killed and the Promise is rejected if the process does not exit within wait milliseconds. On other platforms, first the process is sent the default signal, SIGTERM. After wait milliseconds, it is sent SIGKILL. After another wait milliseconds, an error is thrown.

    Parameters

    • childProcess: ChildProcess

      Child process to kill

    • Default value wait: number = 30000

      Number of milliseconds to wait before sending SIGKILL and then erroring, default is 30000 ms

    Returns Promise<void>

spawnAndLog

  • Spawn a process, log its output, and return a Promise of its results. The command is spawned using cross-spawn. A DelimitedWriteProgressLogDecorator, using newlines as delimiters, is created from the provided log. The default command timeout is 10 minutes. The default [[SpawnLogOptions#errorFinder]] sets the error property if the command exits with a non-zero status or is killed by a signal. If the process is killed due to a signal or the errorFinder returns true, the returned code property will be non-zero.

    deprecated

    use spawnLog

    Parameters

    • log: ProgressLog

      Logger to write stdout and stderr to

    • cmd: string

      Command to run.

    • Default value args: string[] = []

      Arguments to command.

    • Default value opts: SpawnAndLogOptions = {}

      Options for spawn, spawnPromise, and spawnAndLog.

    Returns Promise<SpawnLogResult>

    A promise that provides information on the child process and its execution result, including if the exit status was non-zero or the process was killed by a signal. The promise is only rejected with an ExecPromiseError if there is an error spawning the process.

spawnLog

  • Spawn a process, logging its standard output and standard error, and return a Promise of its results. The command is spawned using cross-spawn. A DelimitedWriteProgressLogDecorator, using newlines as delimiters, is created from the provided opts.log. The default command timeout is 10 minutes. The default [[SpawnLogOptions#errorFinder]] sets the error property if the command exits with a non-zero status or is killed by a signal. If the process is killed due to a signal or the errorFinder returns true, the returned code property will be non-zero.

    Parameters

    • cmd: string

      Command to run.

    • args: string[]

      Arguments to command.

    • opts: SpawnLogOptions

      Options for spawn, spawnPromise, and spawnLog.

    Returns Promise<SpawnLogResult>

    A promise that provides information on the child process and its execution result, including if the exit status was non-zero or the process was killed by a signal. The promise is only rejected with an ExecPromiseError if there is an error spawning the process.

Generated using TypeDoc