Skip to content

Modules | @vltpkg/promise-spawn

Classes

SpawnPromise<O, T>

Subtype of Promise returned by promiseSpawn.

Resolution value is inferred from the provided options.

Extends

Type Parameters

O extends PromiseSpawnOptions

T extends object = object

Constructors

new SpawnPromise()
new SpawnPromise<O, T>(
command,
args,
opts,
extra): SpawnPromise<O, T>
Parameters

command: string

args: string[]

opts: O

extra: T = ...

Returns

SpawnPromise<O, T>

Overrides

Promise<SpawnResultByOptions<O> & T>.constructor

Defined in

src/promise-spawn/src/index.ts:234

Properties

[toStringTag]
[toStringTag]: string = 'SpawnPromise';
Overrides

Promise.[toStringTag]

Defined in

src/promise-spawn/src/index.ts:218

process
process: ChildProcessByOptions<O>

The spawned process this promise references

Defined in

src/promise-spawn/src/index.ts:221

stdin
stdin: null | Writable & O extends PromiseSpawnOptionsNoStdin ? null : Writable;

Expose the child process stdin, if available

Defined in

src/promise-spawn/src/index.ts:224

Accessors

[species]
get static species: PromiseConstructor

Set static Symbol.species back to the base Promise class so that v8 doesn’t get confused by the changed constructor signature.

Returns

PromiseConstructor

Overrides

Promise.[species]

Defined in

src/promise-spawn/src/index.ts:230

Methods

catch()
catch<TResult>(onrejected?): Promise<SpawnResult & object & T | TResult>

Attaches a callback for only the rejection of the Promise.

Type Parameters

TResult = never

Parameters

onrejected?: null | (reason) => TResult | PromiseLike<TResult>

The callback to execute when the Promise is rejected.

Returns

Promise<SpawnResult & object & T | TResult>

A Promise for the completion of the callback.

Inherited from

Promise.catch

Defined in

node_modules/.pnpm/[email protected]/node_modules/typescript/lib/lib.es5.d.ts:1557

finally()
finally(onfinally?): Promise<SpawnResult & object & T>

Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The resolved value cannot be modified from the callback.

Parameters

onfinally?: null | () => void

The callback to execute when the Promise is settled (fulfilled or rejected).

Returns

Promise<SpawnResult & object & T>

A Promise for the completion of the callback.

Inherited from

Promise.finally

Defined in

node_modules/.pnpm/[email protected]/node_modules/typescript/lib/lib.es2018.promise.d.ts:29

then()
then<TResult1, TResult2>(onfulfilled?, onrejected?): Promise<TResult1 | TResult2>

Attaches callbacks for the resolution and/or rejection of the Promise.

Type Parameters

TResult1 = SpawnResult & object & T

TResult2 = never

Parameters

onfulfilled?: null | (value) => TResult1 | PromiseLike<TResult1>

The callback to execute when the Promise is resolved.

onrejected?: null | (reason) => TResult2 | PromiseLike<TResult2>

The callback to execute when the Promise is rejected.

Returns

Promise<TResult1 | TResult2>

A Promise for the completion of which ever callback is executed.

Inherited from

Promise.then

Defined in

node_modules/.pnpm/[email protected]/node_modules/typescript/lib/lib.es5.d.ts:1550

all()
all(values)
static all<T>(values): Promise<Awaited<T>[]>

Creates a Promise that is resolved with an array of results when all of the provided Promises resolve, or rejected when any Promise is rejected.

Type Parameters

T

Parameters

values: Iterable<T | PromiseLike<T>>

An iterable of Promises.

Returns

Promise<Awaited<T>[]>

A new Promise.

Inherited from

Promise.all

Defined in

node_modules/.pnpm/[email protected]/node_modules/typescript/lib/lib.es2015.iterable.d.ts:225

all(values)
static all<T>(values): Promise<{ -readonly [P in string | number | symbol]: Awaited<T[P<P>]> }>

Creates a Promise that is resolved with an array of results when all of the provided Promises resolve, or rejected when any Promise is rejected.

Type Parameters

T extends [] | readonly unknown[]

Parameters

values: T

An array of Promises.

Returns

Promise<{ -readonly [P in string | number | symbol]: Awaited<T[P<P>]> }>

A new Promise.

Inherited from

Promise.all

Defined in

node_modules/.pnpm/[email protected]/node_modules/typescript/lib/lib.es2015.promise.d.ts:39

allSettled()
allSettled(values)
static allSettled<T>(values): Promise<{ -readonly [P in string | number | symbol]: PromiseSettledResult<Awaited<T[P<P>]>> }>

Creates a Promise that is resolved with an array of results when all of the provided Promises resolve or reject.

Type Parameters

T extends [] | readonly unknown[]

Parameters

values: T

An array of Promises.

Returns

Promise<{ -readonly [P in string | number | symbol]: PromiseSettledResult<Awaited<T[P<P>]>> }>

A new Promise.

Inherited from

Promise.allSettled

Defined in

node_modules/.pnpm/[email protected]/node_modules/typescript/lib/lib.es2020.promise.d.ts:38

allSettled(values)
static allSettled<T>(values): Promise<PromiseSettledResult<Awaited<T>>[]>

Creates a Promise that is resolved with an array of results when all of the provided Promises resolve or reject.

Type Parameters

T

Parameters

values: Iterable<T | PromiseLike<T>>

An array of Promises.

Returns

Promise<PromiseSettledResult<Awaited<T>>[]>

A new Promise.

Inherited from

Promise.allSettled

Defined in

node_modules/.pnpm/[email protected]/node_modules/typescript/lib/lib.es2020.promise.d.ts:46

any()
any(values)
static any<T>(values): Promise<Awaited<T[number]>>

The any function returns a promise that is fulfilled by the first given promise to be fulfilled, or rejected with an AggregateError containing an array of rejection reasons if all of the given promises are rejected. It resolves all elements of the passed iterable to promises as it runs this algorithm.

Type Parameters

T extends [] | readonly unknown[]

Parameters

values: T

An array or iterable of Promises.

Returns

Promise<Awaited<T[number]>>

A new Promise.

Inherited from

Promise.any

Defined in

node_modules/.pnpm/[email protected]/node_modules/typescript/lib/lib.es2021.promise.d.ts:40

any(values)
static any<T>(values): Promise<Awaited<T>>

The any function returns a promise that is fulfilled by the first given promise to be fulfilled, or rejected with an AggregateError containing an array of rejection reasons if all of the given promises are rejected. It resolves all elements of the passed iterable to promises as it runs this algorithm.

Type Parameters

T

Parameters

values: Iterable<T | PromiseLike<T>>

An array or iterable of Promises.

Returns

Promise<Awaited<T>>

A new Promise.

Inherited from

Promise.any

Defined in

node_modules/.pnpm/[email protected]/node_modules/typescript/lib/lib.es2021.promise.d.ts:47

race()
race(values)
static race<T>(values): Promise<Awaited<T>>

Creates a Promise that is resolved or rejected when any of the provided Promises are resolved or rejected.

Type Parameters

T

Parameters

values: Iterable<T | PromiseLike<T>>

An iterable of Promises.

Returns

Promise<Awaited<T>>

A new Promise.

Inherited from

Promise.race

Defined in

node_modules/.pnpm/[email protected]/node_modules/typescript/lib/lib.es2015.iterable.d.ts:233

race(values)
static race<T>(values): Promise<Awaited<T[number]>>

Creates a Promise that is resolved or rejected when any of the provided Promises are resolved or rejected.

Type Parameters

T extends [] | readonly unknown[]

Parameters

values: T

An array of Promises.

Returns

Promise<Awaited<T[number]>>

A new Promise.

Inherited from

Promise.race

Defined in

node_modules/.pnpm/[email protected]/node_modules/typescript/lib/lib.es2015.promise.d.ts:50

reject()
static reject<T>(reason?): Promise<T>

Creates a new rejected promise for the provided reason.

Type Parameters

T = never

Parameters

reason?: any

The reason the promise was rejected.

Returns

Promise<T>

A new rejected Promise.

Inherited from

Promise.reject

Defined in

node_modules/.pnpm/[email protected]/node_modules/typescript/lib/lib.es2015.promise.d.ts:60

resolve()
resolve(undefined)
static resolve(): Promise<void>

Creates a new resolved promise.

Returns

Promise<void>

A resolved promise.

Inherited from

Promise.resolve

Defined in

node_modules/.pnpm/[email protected]/node_modules/typescript/lib/lib.es2015.promise.d.ts:66

resolve(value)
static resolve<T>(value): Promise<Awaited<T>>

Creates a new resolved promise for the provided value.

Type Parameters

T

Parameters

value: T

A promise.

Returns

Promise<Awaited<T>>

A promise whose internal state matches the provided promise.

Inherited from

Promise.resolve

Defined in

node_modules/.pnpm/[email protected]/node_modules/typescript/lib/lib.es2015.promise.d.ts:72

resolve(value)
static resolve<T>(value): Promise<Awaited<T>>

Creates a new resolved promise for the provided value.

Type Parameters

T

Parameters

value: T | PromiseLike<T>

A promise.

Returns

Promise<Awaited<T>>

A promise whose internal state matches the provided promise.

Inherited from

Promise.resolve

Defined in

node_modules/.pnpm/[email protected]/node_modules/typescript/lib/lib.es2015.promise.d.ts:78

Type Aliases

ChildProcessByOptions<T>

type ChildProcessByOptions<T>: ChildProcess & object;

Type declaration

stderr
stderr: T extends PromiseSpawnOptionsNoStderr ? null : Exclude<ChildProcess["stderr"], null>;
stdin
stdin: T extends PromiseSpawnOptionsNoStdin ? null : Exclude<ChildProcess["stdin"], null>;
stdout
stdout: T extends PromiseSpawnOptionsNoStdout ? null : Exclude<ChildProcess["stdout"], null>;

Type Parameters

T extends PromiseSpawnOptions

Defined in

src/promise-spawn/src/index.ts:199


IOTypeNoPipe

type IOTypeNoPipe: Exclude<IOType, IOTypePipe>;

Defined in

src/promise-spawn/src/index.ts:20


IOTypePipe

type IOTypePipe: "overlapped" | "pipe" | null | undefined;

Defined in

src/promise-spawn/src/index.ts:21


PromiseSpawnOptions

type PromiseSpawnOptions: SpawnOptions & object;

Type declaration

acceptFail?
optional acceptFail: boolean;
stdioString?
optional stdioString: boolean;

Defined in

src/promise-spawn/src/index.ts:22


PromiseSpawnOptionsBuffer

type PromiseSpawnOptionsBuffer: PromiseSpawnOptions & object;

Type declaration

stdioString
stdioString: false

Defined in

src/promise-spawn/src/index.ts:29


PromiseSpawnOptionsNoStderr

type PromiseSpawnOptionsNoStderr: PromiseSpawnOptions & object;

Type declaration

stdio
stdio: IOTypeNoPipe | IOTypeNoPipe[] | [Exclude<StdioOptions, IOType>[number] | undefined, Exclude<StdioOptions, IOType>[number] | undefined, IOTypeNoPipe];

Defined in

src/promise-spawn/src/index.ts:97


PromiseSpawnOptionsNoStdin

type PromiseSpawnOptionsNoStdin: PromiseSpawnOptions & object;

Type declaration

stdio
stdio: IOTypeNoPipe | IOTypeNoPipe[] | [IOTypeNoPipe | number, Exclude<StdioOptions, IOType>[number], Exclude<StdioOptions, IOType>[number]];

Defined in

src/promise-spawn/src/index.ts:41


PromiseSpawnOptionsNoStdout

type PromiseSpawnOptionsNoStdout: PromiseSpawnOptions & object;

Type declaration

stdio
stdio: IOTypeNoPipe | IOTypeNoPipe[] | [Exclude<StdioOptions, IOType>[number] | undefined, IOTypeNoPipe, Exclude<StdioOptions, IOType>[number]];

Defined in

src/promise-spawn/src/index.ts:68


PromiseSpawnOptionsStderr

type PromiseSpawnOptionsStderr: PromiseSpawnOptions & object;

Type declaration

stdio?
optional stdio: Exclude<IOTypePipe, null> | [Exclude<StdioOptions, IOType>[number] | undefined, Exclude<StdioOptions, IOType>[number] | undefined, IOTypePipe];

Defined in

src/promise-spawn/src/index.ts:79


PromiseSpawnOptionsStderrBuffer

type PromiseSpawnOptionsStderrBuffer: PromiseSpawnOptionsStderr & object;

Type declaration

stdioString
stdioString: false

Defined in

src/promise-spawn/src/index.ts:93


PromiseSpawnOptionsStderrString

type PromiseSpawnOptionsStderrString: PromiseSpawnOptionsStderr & object;

Type declaration

stdioString?
optional stdioString: true;

Defined in

src/promise-spawn/src/index.ts:89


PromiseSpawnOptionsStdin

type PromiseSpawnOptionsStdin: PromiseSpawnOptions & object;

Type declaration

stdio?
optional stdio: Exclude<IOTypePipe, null> | [IOTypePipe, Exclude<StdioOptions, IOType>[number], Exclude<StdioOptions, IOType>[number]];

Defined in

src/promise-spawn/src/index.ts:32


PromiseSpawnOptionsStdout

type PromiseSpawnOptionsStdout: PromiseSpawnOptions & object;

Type declaration

stdio?
optional stdio: Exclude<IOTypePipe, null> | [Exclude<StdioOptions, IOType>[number] | undefined, IOTypePipe, Exclude<StdioOptions, IOType>[number]];

Defined in

src/promise-spawn/src/index.ts:51


PromiseSpawnOptionsStdoutBuffer

type PromiseSpawnOptionsStdoutBuffer: PromiseSpawnOptionsStdout & object;

Type declaration

stdioString
stdioString: false

Defined in

src/promise-spawn/src/index.ts:64


PromiseSpawnOptionsStdoutString

type PromiseSpawnOptionsStdoutString: PromiseSpawnOptionsStdout & object;

Type declaration

stdioString?
optional stdioString: true;

Defined in

src/promise-spawn/src/index.ts:60


PromiseSpawnOptionsString

type PromiseSpawnOptionsString: PromiseSpawnOptions & object;

Type declaration

stdioString?
optional stdioString: true;

Defined in

src/promise-spawn/src/index.ts:26


SpawnResult

type SpawnResult: object;

Type declaration

args
args: string[];
command
command: string
cwd
cwd: string
signal
signal: NodeJS.Signals | null
status
status: number | null
stderr
stderr: Buffer | string | null
stdout
stdout: Buffer | string | null

Defined in

src/promise-spawn/src/index.ts:128


SpawnResultBuffer

type SpawnResultBuffer: SpawnResult & object;

Type declaration

stderr
stderr: Buffer | null
stdout
stdout: Buffer | null

Defined in

src/promise-spawn/src/index.ts:141


SpawnResultByOptions<T>

type SpawnResultByOptions<T>: SpawnResult & object;

Type declaration

stderr
stderr: T extends PromiseSpawnOptionsNoStderr ? null : T extends PromiseSpawnOptionsStderrBuffer ? Buffer : T extends PromiseSpawnOptionsStderrString ? string : T extends PromiseSpawnOptionsBuffer ? Buffer | null : T extends PromiseSpawnOptionsString ? string | null : Buffer | string | null;
stdout
stdout: T extends PromiseSpawnOptionsNoStdout ? null : T extends PromiseSpawnOptionsStdoutBuffer ? Buffer : T extends PromiseSpawnOptionsStdoutString ? string : T extends PromiseSpawnOptionsBuffer ? Buffer | null : T extends PromiseSpawnOptionsString ? string | null : Buffer | string | null;

Type Parameters

T extends PromiseSpawnOptions

Defined in

src/promise-spawn/src/index.ts:183


SpawnResultNoStderr

type SpawnResultNoStderr: SpawnResult & object;

Type declaration

stderr
stderr: null

Defined in

src/promise-spawn/src/index.ts:166


SpawnResultNoStdio

type SpawnResultNoStdio: SpawnResult & object;

Type declaration

stderr
stderr: null
stdout
stdout: null

Defined in

src/promise-spawn/src/index.ts:170


SpawnResultNoStdout

type SpawnResultNoStdout: SpawnResult & object;

Type declaration

stdout
stdout: null

Defined in

src/promise-spawn/src/index.ts:154


SpawnResultStderr

type SpawnResultStderr: SpawnResult & object;

Type declaration

stderr
stderr: Buffer | string

Defined in

src/promise-spawn/src/index.ts:157


SpawnResultStderrBuffer

type SpawnResultStderrBuffer: SpawnResultBuffer & object;

Type declaration

stderr
stderr: Buffer

Defined in

src/promise-spawn/src/index.ts:163


SpawnResultStderrString

type SpawnResultStderrString: SpawnResultString & object;

Type declaration

stderr
stderr: string

Defined in

src/promise-spawn/src/index.ts:160


SpawnResultStdioBuffers

type SpawnResultStdioBuffers: SpawnResult & object;

Type declaration

stderr
stderr: Buffer
stdout
stdout: Buffer

Defined in

src/promise-spawn/src/index.ts:178


SpawnResultStdioStrings

type SpawnResultStdioStrings: SpawnResult & object;

Type declaration

stderr
stderr: string
stdout
stdout: string

Defined in

src/promise-spawn/src/index.ts:174


SpawnResultStdout

type SpawnResultStdout: SpawnResult & object;

Type declaration

stdout
stdout: Buffer | string

Defined in

src/promise-spawn/src/index.ts:145


SpawnResultStdoutBuffer

type SpawnResultStdoutBuffer: SpawnResultBuffer & object;

Type declaration

stdout
stdout: Buffer

Defined in

src/promise-spawn/src/index.ts:151


SpawnResultStdoutString

type SpawnResultStdoutString: SpawnResultString & object;

Type declaration

stdout
stdout: string

Defined in

src/promise-spawn/src/index.ts:148


SpawnResultString

type SpawnResultString: SpawnResult & object;

Type declaration

stderr
stderr: string | null
stdout
stdout: string | null

Defined in

src/promise-spawn/src/index.ts:137

Functions

promiseSpawn()

function promiseSpawn<O, E>(
command,
args,
opts,
extra,
): SpawnPromise<O, E>

Spawn the specified command, and return a promise that resolves when the process closes or has an error.

Type Parameters

O extends PromiseSpawnOptions = SpawnOptions & object & object & object & object & object

E extends object = object

Parameters

command: string

args: string[]

opts: O = ...

extra: E = ...

Returns

SpawnPromise<O, E>

Defined in

src/promise-spawn/src/index.ts:292