@azure/core-process package

Classes

ProcessError

An error raised while resolving or executing a process.

The captured output is non-enumerable so ordinary logging and serialization do not expose it accidentally.

Interfaces

ExecFileOptions

Options for execFile.

ExecFileOptionsWithBufferEncoding

Buffer-encoding options for execFile.

ExecFileOptionsWithStringEncoding

String-encoding options for execFile.

ExecFileResult

Buffered output from execFile.

ProcessErrorOptions

Structured details for a ProcessError.

ProcessOptions

Options shared by safe process operations.

ResolveExecutableOptions

Options used while resolving an executable.

SpawnOptions

Options for spawn.

SpawnSyncOptions

Options for spawnSync.

SpawnSyncOptionsWithBufferEncoding

Buffer-encoding options for spawnSync.

SpawnSyncOptionsWithStringEncoding

String-encoding options for spawnSync.

Functions

execFile(string, readonly string[])

Runs a process to completion and buffers its output.

execFile(string, undefined | (readonly string[]), ExecFileOptionsWithBufferEncoding)

Runs a process to completion and buffers its output.

execFile(string, undefined | (readonly string[]), ExecFileOptionsWithStringEncoding)

Runs a process to completion and buffers its output.

execFile(string, readonly string[], ExecFileOptions)

Runs a process to completion and buffers its output.

isProcessError(unknown)

Checks whether an unknown value is a ProcessError.

resolveExecutable(string, ResolveExecutableOptions)

Resolves an executable using an explicit working directory and environment.

spawn(string, readonly string[], SpawnOptions)

Starts a process without using an ambient operating-system shell.

spawnSync(string, undefined | (readonly string[]), SpawnSyncOptionsWithStringEncoding)

Starts a process synchronously without using an ambient operating-system shell.

spawnSync(string, readonly string[], SpawnSyncOptionsWithBufferEncoding)

Starts a process synchronously without using an ambient operating-system shell.

spawnSync(string, undefined | (readonly string[]), SpawnSyncOptions)

Starts a process synchronously without using an ambient operating-system shell.

Function Details

execFile(string, readonly string[])

Runs a process to completion and buffers its output.

function execFile(command: string, args?: readonly string[]): Promise<ExecFileResult<string>>

Parameters

command

string

The executable name or path.

args

readonly string[]

Arguments passed to the executable.

Returns

Promise<ExecFileResult<string>>

Buffered standard output and standard error.

execFile(string, undefined | (readonly string[]), ExecFileOptionsWithBufferEncoding)

Runs a process to completion and buffers its output.

function execFile(command: string, args: undefined | (readonly string[]), options: ExecFileOptionsWithBufferEncoding): Promise<ExecFileResult<Buffer>>

Parameters

command

string

The executable name or path.

args

undefined | (readonly string[])

Arguments passed to the executable.

options
ExecFileOptionsWithBufferEncoding

Process options.

Returns

Promise<ExecFileResult<Buffer>>

Buffered standard output and standard error.

execFile(string, undefined | (readonly string[]), ExecFileOptionsWithStringEncoding)

Runs a process to completion and buffers its output.

function execFile(command: string, args: undefined | (readonly string[]), options: ExecFileOptionsWithStringEncoding): Promise<ExecFileResult<string>>

Parameters

command

string

The executable name or path.

args

undefined | (readonly string[])

Arguments passed to the executable.

options
ExecFileOptionsWithStringEncoding

Process options.

Returns

Promise<ExecFileResult<string>>

Buffered standard output and standard error.

execFile(string, readonly string[], ExecFileOptions)

Runs a process to completion and buffers its output.

function execFile(command: string, args?: readonly string[], options?: ExecFileOptions): Promise<ExecFileResult<string | Buffer>>

Parameters

command

string

The executable name or path.

args

readonly string[]

Arguments passed to the executable.

options
ExecFileOptions

Process options.

Returns

Promise<ExecFileResult<string | Buffer>>

Buffered standard output and standard error.

isProcessError(unknown)

Checks whether an unknown value is a ProcessError.

function isProcessError(error: unknown): error

Parameters

error

unknown

The value to check.

Returns

error

Whether the value is a process error.

resolveExecutable(string, ResolveExecutableOptions)

Resolves an executable using an explicit working directory and environment.

function resolveExecutable(command: string, options?: ResolveExecutableOptions): string | undefined

Parameters

command

string

The executable name or path. It must not contain arguments.

options
ResolveExecutableOptions

Resolution options.

Returns

string | undefined

The absolute executable path, or undefined when no supported file is found.

spawn(string, readonly string[], SpawnOptions)

Starts a process without using an ambient operating-system shell.

function spawn(command: string, args?: readonly string[], options?: SpawnOptions): childProcess.ChildProcess

Parameters

command

string

The executable name or path.

args

readonly string[]

Arguments passed to the executable.

options
SpawnOptions

Process options.

Returns

childProcess.ChildProcess

The started child process.

spawnSync(string, undefined | (readonly string[]), SpawnSyncOptionsWithStringEncoding)

Starts a process synchronously without using an ambient operating-system shell.

function spawnSync(command: string, args: undefined | (readonly string[]), options: SpawnSyncOptionsWithStringEncoding): childProcess.SpawnSyncReturns<string>

Parameters

command

string

The executable name or path.

args

undefined | (readonly string[])

Arguments passed to the executable.

options
SpawnSyncOptionsWithStringEncoding

Process options.

Returns

childProcess.SpawnSyncReturns<string>

The synchronous process result.

spawnSync(string, readonly string[], SpawnSyncOptionsWithBufferEncoding)

Starts a process synchronously without using an ambient operating-system shell.

function spawnSync(command: string, args?: readonly string[], options?: SpawnSyncOptionsWithBufferEncoding): childProcess.SpawnSyncReturns<Buffer>

Parameters

command

string

The executable name or path.

args

readonly string[]

Arguments passed to the executable.

options
SpawnSyncOptionsWithBufferEncoding

Process options.

Returns

childProcess.SpawnSyncReturns<Buffer>

The synchronous process result.

spawnSync(string, undefined | (readonly string[]), SpawnSyncOptions)

Starts a process synchronously without using an ambient operating-system shell.

function spawnSync(command: string, args: undefined | (readonly string[]), options: SpawnSyncOptions): childProcess.SpawnSyncReturns<string | Buffer>

Parameters

command

string

The executable name or path.

args

undefined | (readonly string[])

Arguments passed to the executable.

options
SpawnSyncOptions

Process options.

Returns

childProcess.SpawnSyncReturns<string | Buffer>

The synchronous process result.