Home Reference Source Test Repository

Function

Static Public Summary
public

Finds the actual executable and parameters to run on Windows.

public

spawn(exe: string, params: Array<string>, opts: Object): Observable<string>

Spawns a process attached as a child of the current process.

public

spawnDetached(exe: string, params: Array<string>, opts: Object): Observable<string>

Spawns a process but detached from the current process.

public

Spawns a process but detached from the current process.

public

spawnPromise(exe: string, params: Array<string>, opts: Object): Promise<string>

Spawns a process as a child process.

Static Public

public findActualExecutable(exe: string, args: Array<string>): Object source

import {findActualExecutable} from 'spawn-rx/src/index.js'

Finds the actual executable and parameters to run on Windows. This method mimics the POSIX behavior of being able to run scripts as executables by replacing the passed-in executable with the script runner, for PowerShell, CMD, and node scripts.

This method also does the work of running down PATH, which spawn on Windows also doesn't do, unlike on POSIX.

Params:

NameTypeAttributeDescription
exe string

The executable to run

args Array<string>

The arguments to run

Return:

Object

The cmd and args to run

Return Properties:

NameTypeAttributeDescription
cmd string

The command to pass to spawn

args Array<string>

The arguments to pass to spawn

public spawn(exe: string, params: Array<string>, opts: Object): Observable<string> source

import {spawn} from 'spawn-rx/src/index.js'

Spawns a process attached as a child of the current process.

Params:

NameTypeAttributeDescription
exe string

The executable to run

params Array<string>

The parameters to pass to the child

opts Object

Options to pass to spawn.

Return:

Observable<string>

Returns an Observable that when subscribed to, will create a child process. The process output will be streamed to this Observable, and if unsubscribed from, the process will be terminated early. If the process terminates with a non-zero value, the Observable will terminate with onError.

public spawnDetached(exe: string, params: Array<string>, opts: Object): Observable<string> source

import {spawnDetached} from 'spawn-rx/src/index.js'

Spawns a process but detached from the current process. The process is put into its own Process Group that can be killed by unsubscribing from the return Observable.

Params:

NameTypeAttributeDescription
exe string

The executable to run

params Array<string>

The parameters to pass to the child

opts Object

Options to pass to spawn.

Return:

Observable<string>

Returns an Observable that when subscribed to, will create a detached process. The process output will be streamed to this Observable, and if unsubscribed from, the process will be terminated early. If the process terminates with a non-zero value, the Observable will terminate with onError.

public spawnDetachedPromise(exe: string, params: Array<string>, opts: Object): Promise<string> source

import {spawnDetachedPromise} from 'spawn-rx/src/index.js'

Spawns a process but detached from the current process. The process is put into its own Process Group.

Params:

NameTypeAttributeDescription
exe string

The executable to run

params Array<string>

The parameters to pass to the child

opts Object

Options to pass to spawn.

Return:

Promise<string>

Returns an Promise that represents a detached process. The value returned is the process output. If the process terminates with a non-zero value, the Promise will resolve with an Error.

public spawnPromise(exe: string, params: Array<string>, opts: Object): Promise<string> source

import {spawnPromise} from 'spawn-rx/src/index.js'

Spawns a process as a child process.

Params:

NameTypeAttributeDescription
exe string

The executable to run

params Array<string>

The parameters to pass to the child

opts Object

Options to pass to spawn.

Return:

Promise<string>

Returns an Promise that represents a child process. The value returned is the process output. If the process terminates with a non-zero value, the Promise will resolve with an Error.