@vltpkg/promise-spawn 0.0.0-0.1730724342581 → 0.0.0-11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -43
- package/dist/esm/index.d.ts +60 -59
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +49 -32
- package/dist/esm/index.js.map +1 -1
- package/package.json +21 -14
package/README.md
CHANGED
|
@@ -2,27 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
# @vltpkg/promise-spawn
|
|
4
4
|
|
|
5
|
-
Spawn a process and return a promise that resolves when the process
|
|
5
|
+
Spawn a process and return a promise that resolves when the process
|
|
6
|
+
closes. Fork of
|
|
7
|
+
[`@npmcli/promise-spawn`](http://npm.im/@npmcli/promise-spawn).
|
|
6
8
|
|
|
7
|
-
**[Usage](#usage)**
|
|
8
|
-
·
|
|
9
|
-
**[API](#api)**
|
|
10
|
-
·
|
|
9
|
+
**[Usage](#usage)** · **[API](#api)** ·
|
|
11
10
|
**[Caveats](#typescript-inference-caveats)**
|
|
12
11
|
|
|
13
12
|
## Differences from `@npmcli/promise-spawn`
|
|
14
13
|
|
|
15
|
-
- A `SpawnPromise(cmd, args, options)` class is added that
|
|
16
|
-
|
|
14
|
+
- A `SpawnPromise(cmd, args, options)` class is added that handles
|
|
15
|
+
most of the functionality.
|
|
17
16
|
- `promiseSpawn.open()` is removed
|
|
18
|
-
- When run as root, it just runs the command as root, it doesn't
|
|
19
|
-
|
|
17
|
+
- When run as root, it just runs the command as root, it doesn't try
|
|
18
|
+
to infer the uid/gid based on the owner of the cwd..
|
|
20
19
|
- No special handling for `shell: true` processes, and thus, no
|
|
21
|
-
escaping of arguments in that case. (It's just passed through
|
|
22
|
-
|
|
23
|
-
- Fully type-aware, even down to inferring the presence and type
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
escaping of arguments in that case. (It's just passed through to
|
|
21
|
+
Node's `spawn()` method.)
|
|
22
|
+
- Fully type-aware, even down to inferring the presence and type of
|
|
23
|
+
`stdout` and `stderr` properties, as well as the properties added
|
|
24
|
+
via the optional `extra` argument.
|
|
26
25
|
|
|
27
26
|
## Usage
|
|
28
27
|
|
|
@@ -65,39 +64,38 @@ Result or error will be decorated with the properties in the `extra`
|
|
|
65
64
|
object. You can use this to attach some helpful info about _why_ the
|
|
66
65
|
command is being run, if it makes sense for your use case.
|
|
67
66
|
|
|
68
|
-
If `stdio` is set to anything other than `'inherit'`, then the
|
|
69
|
-
will be decorated with `stdout` and `stderr` values. If
|
|
70
|
-
set to `true`, these will be strings. Otherwise they
|
|
71
|
-
objects.
|
|
67
|
+
If `stdio` is set to anything other than `'inherit'`, then the
|
|
68
|
+
result/error will be decorated with `stdout` and `stderr` values. If
|
|
69
|
+
`stdioString` is set to `true`, these will be strings. Otherwise they
|
|
70
|
+
will be Buffer objects.
|
|
72
71
|
|
|
73
|
-
Returned promise is decorated with the `stdin` stream if the process
|
|
74
|
-
to pipe from `stdin`. Writing to this stream writes to the
|
|
75
|
-
spawned process.
|
|
72
|
+
Returned promise is decorated with the `stdin` stream if the process
|
|
73
|
+
is set to pipe from `stdin`. Writing to this stream writes to the
|
|
74
|
+
`stdin` of the spawned process.
|
|
76
75
|
|
|
77
76
|
#### Options
|
|
78
77
|
|
|
79
|
-
- `stdioString` Boolean, default `true`. Return stdout/stderr
|
|
80
|
-
|
|
81
|
-
- `acceptFail` Boolean, default `false`. If true, then a process
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
- Any other options for `child_process.spawn` can be passed as
|
|
88
|
-
well.
|
|
78
|
+
- `stdioString` Boolean, default `true`. Return stdout/stderr output
|
|
79
|
+
as trimmed strings rather than buffers.
|
|
80
|
+
- `acceptFail` Boolean, default `false`. If true, then a process that
|
|
81
|
+
closes with `status` other than 0, or `signal` other than `null`,
|
|
82
|
+
will reject the promise. If true, then failure exits resolve the
|
|
83
|
+
promise normally. This is useful when you need to run a process
|
|
84
|
+
where an exit status of `>0` is informative, to avoid creating an
|
|
85
|
+
Error object for it.
|
|
86
|
+
- Any other options for `child_process.spawn` can be passed as well.
|
|
89
87
|
|
|
90
88
|
## TypeScript Inference Caveats
|
|
91
89
|
|
|
92
90
|
_Workaround:_
|
|
93
91
|
|
|
94
|
-
If you provide a complex stdio option like `['pipe', 'inherit']`,
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
92
|
+
If you provide a complex stdio option like `['pipe', 'inherit']`, then
|
|
93
|
+
this will of course mean that `stdin` is set to a writable stream,
|
|
94
|
+
`stderr` is set to a readable stream (because that's the default), but
|
|
95
|
+
`stdout` is set to `null`.
|
|
98
96
|
|
|
99
|
-
The types will accurately infer this from the type of the
|
|
100
|
-
|
|
97
|
+
The types will accurately infer this from the type of the argument.
|
|
98
|
+
However, observe this incorrect result:
|
|
101
99
|
|
|
102
100
|
```
|
|
103
101
|
const result = await promiseSpawn(cmd, args, {
|
|
@@ -109,13 +107,13 @@ result.stderr
|
|
|
109
107
|
// ^? string
|
|
110
108
|
```
|
|
111
109
|
|
|
112
|
-
TS will infer the `options.stdio` property to be
|
|
113
|
-
'inherit')[]`. Since the second item of such an array
|
|
114
|
-
set to `'pipe'` at some point, TS will infer the return
|
|
115
|
-
include `{ stdout: string }`.
|
|
110
|
+
TS will infer the `options.stdio` property to be
|
|
111
|
+
`('pipe' | 'inherit')[]`. Since the second item of such an array
|
|
112
|
+
_might_ be set to `'pipe'` at some point, TS will infer the return
|
|
113
|
+
value to include `{ stdout: string }`.
|
|
116
114
|
|
|
117
|
-
To get around this, typecast the field to its literal value. This
|
|
118
|
-
|
|
115
|
+
To get around this, typecast the field to its literal value. This is a
|
|
116
|
+
bit noisy, but works fine:
|
|
119
117
|
|
|
120
118
|
```js
|
|
121
119
|
const result = await promiseSpawn(cmd, args, {
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,71 +1,71 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ChildProcess, IOType, SpawnOptions, StdioOptions } from 'node:child_process';
|
|
2
2
|
export type IOTypeNoPipe = Exclude<IOType, IOTypePipe>;
|
|
3
3
|
export type IOTypePipe = 'overlapped' | 'pipe' | null | undefined;
|
|
4
|
-
export
|
|
4
|
+
export interface PromiseSpawnOptions extends SpawnOptions {
|
|
5
5
|
stdioString?: boolean;
|
|
6
6
|
acceptFail?: boolean;
|
|
7
|
-
}
|
|
8
|
-
export
|
|
7
|
+
}
|
|
8
|
+
export interface PromiseSpawnOptionsString extends PromiseSpawnOptions {
|
|
9
9
|
stdioString?: true;
|
|
10
|
-
}
|
|
11
|
-
export
|
|
10
|
+
}
|
|
11
|
+
export interface PromiseSpawnOptionsBuffer extends PromiseSpawnOptions {
|
|
12
12
|
stdioString: false;
|
|
13
|
-
}
|
|
14
|
-
export
|
|
13
|
+
}
|
|
14
|
+
export interface PromiseSpawnOptionsStdin extends PromiseSpawnOptions {
|
|
15
15
|
stdio?: Exclude<IOTypePipe, null> | [
|
|
16
16
|
stdin?: IOTypePipe,
|
|
17
17
|
stdout?: Exclude<StdioOptions, IOType>[number],
|
|
18
18
|
stderr?: Exclude<StdioOptions, IOType>[number]
|
|
19
19
|
];
|
|
20
|
-
}
|
|
21
|
-
export
|
|
20
|
+
}
|
|
21
|
+
export interface PromiseSpawnOptionsNoStdin extends PromiseSpawnOptions {
|
|
22
22
|
stdio: IOTypeNoPipe | IOTypeNoPipe[] | [
|
|
23
23
|
stdin: IOTypeNoPipe | number,
|
|
24
24
|
stdout?: Exclude<StdioOptions, IOType>[number],
|
|
25
25
|
stderr?: Exclude<StdioOptions, IOType>[number]
|
|
26
26
|
];
|
|
27
|
-
}
|
|
28
|
-
export
|
|
27
|
+
}
|
|
28
|
+
export interface PromiseSpawnOptionsStdout extends PromiseSpawnOptions {
|
|
29
29
|
stdio?: Exclude<IOTypePipe, null> | [
|
|
30
30
|
stdin: Exclude<StdioOptions, IOType>[number] | undefined,
|
|
31
31
|
stdout?: IOTypePipe,
|
|
32
32
|
stderr?: Exclude<StdioOptions, IOType>[number]
|
|
33
33
|
];
|
|
34
|
-
}
|
|
35
|
-
export
|
|
34
|
+
}
|
|
35
|
+
export interface PromiseSpawnOptionsStdoutString extends PromiseSpawnOptionsStdout {
|
|
36
36
|
stdioString?: true;
|
|
37
|
-
}
|
|
38
|
-
export
|
|
37
|
+
}
|
|
38
|
+
export interface PromiseSpawnOptionsStdoutBuffer extends PromiseSpawnOptionsStdout {
|
|
39
39
|
stdioString: false;
|
|
40
|
-
}
|
|
41
|
-
export
|
|
40
|
+
}
|
|
41
|
+
export interface PromiseSpawnOptionsNoStdout extends PromiseSpawnOptions {
|
|
42
42
|
stdio: IOTypeNoPipe | IOTypeNoPipe[] | [
|
|
43
43
|
stdin: Exclude<StdioOptions, IOType>[number] | undefined,
|
|
44
44
|
stdout?: IOTypeNoPipe,
|
|
45
45
|
stderr?: Exclude<StdioOptions, IOType>[number]
|
|
46
46
|
];
|
|
47
|
-
}
|
|
48
|
-
export
|
|
47
|
+
}
|
|
48
|
+
export interface PromiseSpawnOptionsStderr extends PromiseSpawnOptions {
|
|
49
49
|
stdio?: Exclude<IOTypePipe, null> | [
|
|
50
50
|
stdin: Exclude<StdioOptions, IOType>[number] | undefined,
|
|
51
51
|
stdout: Exclude<StdioOptions, IOType>[number] | undefined,
|
|
52
52
|
stderr?: IOTypePipe
|
|
53
53
|
];
|
|
54
|
-
}
|
|
55
|
-
export
|
|
54
|
+
}
|
|
55
|
+
export interface PromiseSpawnOptionsStderrString extends PromiseSpawnOptionsStderr {
|
|
56
56
|
stdioString?: true;
|
|
57
|
-
}
|
|
58
|
-
export
|
|
57
|
+
}
|
|
58
|
+
export interface PromiseSpawnOptionsStderrBuffer extends PromiseSpawnOptionsStderr {
|
|
59
59
|
stdioString: false;
|
|
60
|
-
}
|
|
61
|
-
export
|
|
60
|
+
}
|
|
61
|
+
export interface PromiseSpawnOptionsNoStderr extends PromiseSpawnOptions {
|
|
62
62
|
stdio: IOTypeNoPipe | IOTypeNoPipe[] | [
|
|
63
63
|
stdin: Exclude<StdioOptions, IOType>[number] | undefined,
|
|
64
64
|
stdout: Exclude<StdioOptions, IOType>[number] | undefined,
|
|
65
65
|
stderr: IOTypeNoPipe
|
|
66
66
|
];
|
|
67
|
-
}
|
|
68
|
-
export
|
|
67
|
+
}
|
|
68
|
+
export interface SpawnResult {
|
|
69
69
|
command: string;
|
|
70
70
|
args: string[];
|
|
71
71
|
cwd: string;
|
|
@@ -73,60 +73,61 @@ export type SpawnResult = {
|
|
|
73
73
|
signal: NodeJS.Signals | null;
|
|
74
74
|
stdout: Buffer | string | null;
|
|
75
75
|
stderr: Buffer | string | null;
|
|
76
|
-
}
|
|
77
|
-
export
|
|
76
|
+
}
|
|
77
|
+
export interface SpawnResultString extends SpawnResult {
|
|
78
78
|
stdout: string | null;
|
|
79
79
|
stderr: string | null;
|
|
80
|
-
}
|
|
81
|
-
export
|
|
80
|
+
}
|
|
81
|
+
export interface SpawnResultBuffer extends SpawnResult {
|
|
82
82
|
stdout: Buffer | null;
|
|
83
83
|
stderr: Buffer | null;
|
|
84
|
-
}
|
|
85
|
-
export
|
|
84
|
+
}
|
|
85
|
+
export interface SpawnResultStdout extends SpawnResult {
|
|
86
86
|
stdout: Buffer | string;
|
|
87
|
-
}
|
|
88
|
-
export
|
|
87
|
+
}
|
|
88
|
+
export interface SpawnResultStdoutString extends SpawnResultString {
|
|
89
89
|
stdout: string;
|
|
90
|
-
}
|
|
91
|
-
export
|
|
90
|
+
}
|
|
91
|
+
export interface SpawnResultStdoutBuffer extends SpawnResultBuffer {
|
|
92
92
|
stdout: Buffer;
|
|
93
|
-
}
|
|
94
|
-
export
|
|
93
|
+
}
|
|
94
|
+
export interface SpawnResultNoStdout extends SpawnResult {
|
|
95
95
|
stdout: null;
|
|
96
|
-
}
|
|
97
|
-
export
|
|
96
|
+
}
|
|
97
|
+
export interface SpawnResultStderr extends SpawnResult {
|
|
98
98
|
stderr: Buffer | string;
|
|
99
|
-
}
|
|
100
|
-
export
|
|
99
|
+
}
|
|
100
|
+
export interface SpawnResultStderrString extends SpawnResultString {
|
|
101
101
|
stderr: string;
|
|
102
|
-
}
|
|
103
|
-
export
|
|
102
|
+
}
|
|
103
|
+
export interface SpawnResultStderrBuffer extends SpawnResultBuffer {
|
|
104
104
|
stderr: Buffer;
|
|
105
|
-
}
|
|
106
|
-
export
|
|
105
|
+
}
|
|
106
|
+
export interface SpawnResultNoStderr extends SpawnResult {
|
|
107
107
|
stderr: null;
|
|
108
|
-
}
|
|
109
|
-
export
|
|
108
|
+
}
|
|
109
|
+
export interface SpawnResultNoStdio extends SpawnResult {
|
|
110
110
|
stderr: null;
|
|
111
111
|
stdout: null;
|
|
112
|
-
}
|
|
113
|
-
export
|
|
112
|
+
}
|
|
113
|
+
export interface SpawnResultStdioStrings extends SpawnResult {
|
|
114
114
|
stdout: string;
|
|
115
115
|
stderr: string;
|
|
116
|
-
}
|
|
117
|
-
export
|
|
116
|
+
}
|
|
117
|
+
export interface SpawnResultStdioBuffers extends SpawnResult {
|
|
118
118
|
stdout: Buffer;
|
|
119
119
|
stderr: Buffer;
|
|
120
|
-
}
|
|
121
|
-
export type
|
|
120
|
+
}
|
|
121
|
+
export type Override<T, R> = Omit<T, keyof R> & R;
|
|
122
|
+
export type SpawnResultByOptions<T extends PromiseSpawnOptions> = Override<SpawnResult, {
|
|
122
123
|
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;
|
|
123
124
|
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;
|
|
124
|
-
}
|
|
125
|
-
export type ChildProcessByOptions<T extends PromiseSpawnOptions> = ChildProcess
|
|
125
|
+
}>;
|
|
126
|
+
export type ChildProcessByOptions<T extends PromiseSpawnOptions> = Override<ChildProcess, {
|
|
126
127
|
stdin: T extends PromiseSpawnOptionsNoStdin ? null : Exclude<ChildProcess['stdin'], null>;
|
|
127
128
|
stdout: T extends PromiseSpawnOptionsNoStdout ? null : Exclude<ChildProcess['stdout'], null>;
|
|
128
129
|
stderr: T extends PromiseSpawnOptionsNoStderr ? null : Exclude<ChildProcess['stderr'], null>;
|
|
129
|
-
}
|
|
130
|
+
}>;
|
|
130
131
|
/**
|
|
131
132
|
* Subtype of Promise returned by {@link promiseSpawn}.
|
|
132
133
|
*
|
package/dist/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,YAAY,EACZ,MAAM,EACN,YAAY,EACZ,YAAY,EACb,MAAM,oBAAoB,CAAA;AAY3B,MAAM,MAAM,YAAY,GAAG,OAAO,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;AACtD,MAAM,MAAM,UAAU,GAAG,YAAY,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;AAEjE,MAAM,WAAW,mBAAoB,SAAQ,YAAY;IACvD,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB;AACD,MAAM,WAAW,yBACf,SAAQ,mBAAmB;IAC3B,WAAW,CAAC,EAAE,IAAI,CAAA;CACnB;AACD,MAAM,WAAW,yBACf,SAAQ,mBAAmB;IAC3B,WAAW,EAAE,KAAK,CAAA;CACnB;AACD,MAAM,WAAW,wBACf,SAAQ,mBAAmB;IAC3B,KAAK,CAAC,EACF,OAAO,CAA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,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IAC5C,CAAC,MAAM,CAAC,WAAW,CAAC,SAAiB;IAErC,kDAAkD;IAClD,OAAO,EAAG,qBAAqB,CAAC,CAAC,CAAC,CAAA;IAElC,mDAAmD;IACnD,KAAK,EAAG,qBAAqB,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAA;IAEzC;;;OAGG;IACH,MAAM,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,uBAE1B;gBAGC,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EAAE,EACd,IAAI,EAAE,CAAC,EACP,KAAK,GAAE,CAAW;CAqErB;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAC1B,CAAC,SAAS,mBAAmB,GAAG,+BAA+B,GAC7D,+BAA+B,EACjC,CAAC,SAAS,MAAM,GAAG,MAAM,EACzB,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,IAAI,GAAS,CAAC,EAAE,KAAK,GAAS,CAAC,sBAEjE"}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { error } from '@vltpkg/error-cause';
|
|
2
|
-
import { spawn
|
|
2
|
+
import { spawn } from 'node:child_process';
|
|
3
3
|
const isPipe = (stdio = 'pipe', fd) => stdio === 'pipe' || stdio === 'overlapped' || stdio === null ? true
|
|
4
4
|
: Array.isArray(stdio) ? isPipe(stdio[fd], fd)
|
|
5
5
|
: false;
|
|
@@ -39,40 +39,57 @@ export class SpawnPromise extends Promise {
|
|
|
39
39
|
proc = spawn(command, args, opts);
|
|
40
40
|
const stdout = [];
|
|
41
41
|
const stderr = [];
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
...extra,
|
|
48
|
-
cause: er,
|
|
49
|
-
}));
|
|
50
|
-
proc.on('error', reject);
|
|
51
|
-
if (proc.stdout) {
|
|
52
|
-
proc.stdout
|
|
53
|
-
.on('data', c => stdout.push(c))
|
|
54
|
-
.on('error', er => reject(er));
|
|
55
|
-
}
|
|
56
|
-
if (proc.stderr) {
|
|
57
|
-
proc.stderr
|
|
58
|
-
.on('data', c => stderr.push(c))
|
|
59
|
-
.on('error', er => reject(er));
|
|
60
|
-
}
|
|
61
|
-
proc.on('close', (status, signal) => {
|
|
62
|
-
const result = {
|
|
42
|
+
// Don't use the spread operator on successResult or errorResult
|
|
43
|
+
// as that kills any typechecking for the known keys.
|
|
44
|
+
const reject = (er, status, signal) => {
|
|
45
|
+
const stdio = stdioResult(stdout, stderr, opts);
|
|
46
|
+
const errorResult = {
|
|
63
47
|
command,
|
|
64
48
|
args,
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
signal: signal ?? null,
|
|
69
|
-
...stdioResult(stdout, stderr, opts),
|
|
70
|
-
...extra,
|
|
49
|
+
stdout: stdio.stdout,
|
|
50
|
+
stderr: stdio.stderr,
|
|
51
|
+
cwd: opts.cwd?.toString() ?? process.cwd(),
|
|
71
52
|
};
|
|
72
|
-
if (
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
53
|
+
if (er !== undefined) {
|
|
54
|
+
errorResult.cause = er;
|
|
55
|
+
}
|
|
56
|
+
if (status !== undefined) {
|
|
57
|
+
errorResult.status = status;
|
|
58
|
+
}
|
|
59
|
+
if (signal !== undefined) {
|
|
60
|
+
errorResult.signal = signal;
|
|
61
|
+
}
|
|
62
|
+
Object.assign(errorResult, extra);
|
|
63
|
+
rej(error('command failed', errorResult));
|
|
64
|
+
};
|
|
65
|
+
const resolve = (status, signal) => {
|
|
66
|
+
const stdio = stdioResult(stdout, stderr, opts);
|
|
67
|
+
const successResult = {
|
|
68
|
+
command,
|
|
69
|
+
args,
|
|
70
|
+
status,
|
|
71
|
+
signal,
|
|
72
|
+
stdout: stdio.stdout,
|
|
73
|
+
stderr: stdio.stderr,
|
|
74
|
+
cwd: opts.cwd?.toString() ?? process.cwd(),
|
|
75
|
+
};
|
|
76
|
+
Object.assign(successResult, extra);
|
|
77
|
+
res(successResult);
|
|
78
|
+
};
|
|
79
|
+
proc.on('error', reject);
|
|
80
|
+
proc.stdout
|
|
81
|
+
?.on('data', c => stdout.push(c))
|
|
82
|
+
.on('error', er => reject(er));
|
|
83
|
+
proc.stderr
|
|
84
|
+
?.on('data', c => stderr.push(c))
|
|
85
|
+
.on('error', er => reject(er));
|
|
86
|
+
proc.on('close', (status = null, signal = null) => {
|
|
87
|
+
if ((status || signal) && !opts.acceptFail) {
|
|
88
|
+
reject(undefined, status, signal);
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
resolve(status, signal);
|
|
92
|
+
}
|
|
76
93
|
});
|
|
77
94
|
});
|
|
78
95
|
this.process = proc;
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAGL,KAAK,GAGN,MAAM,eAAe,CAAA;AAEtB,MAAM,MAAM,GAAG,CACb,QAEmB,MAAM,EACzB,EAAU,EACW,EAAE,CACvB,KAAK,KAAK,MAAM,IAAI,KAAK,KAAK,YAAY,IAAI,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI;IACnE,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC9C,CAAC,CAAC,KAAK,CAAA;AA0FT,SAAS,WAAW,CAClB,MAAgB,EAChB,MAAgB,EAChB,CAAI;IAKJ,OAAO;QACL,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI;YACnC,CAAC,CAAC,CAAC,CAAC,WAAW,KAAK,KA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AAC,CAAA;;oBACjC,GAAG,CAAC,MAAM,CAAC,CAAA;YAClB,CAAC,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;QACF,IAAI,CAAC,OAAO,GAAG,IAAI,CAAA;QACnB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAA;IACzB,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAI1B,OAAe,EAAE,IAAc,EAAE,OAAO,EAAO,EAAE,QAAQ,EAAO;IAChE,OAAO,IAAI,YAAY,CAAO,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,CAAA;AAC3D,CAAC","sourcesContent":["import { error } from '@vltpkg/error-cause'\nimport {\n type ChildProcess,\n type IOType,\n spawn,\n type SpawnOptions,\n type StdioOptions,\n} from 'child_process'\n\nconst isPipe = (\n stdio:\n | Exclude<StdioOptions, IOType>[number]\n | StdioOptions = 'pipe',\n fd: number,\n): stdio is IOTypePipe =>\n stdio === 'pipe' || stdio === 'overlapped' || stdio === null ? true\n : Array.isArray(stdio) ? isPipe(stdio[fd], fd)\n : false\n\nexport type IOTypeNoPipe = Exclude<IOType, IOTypePipe>\nexport type IOTypePipe = 'overlapped' | 'pipe' | null | undefined\nexport type PromiseSpawnOptions = SpawnOptions & {\n stdioString?: boolean\n acceptFail?: boolean\n}\nexport type PromiseSpawnOptionsString = PromiseSpawnOptions & {\n stdioString?: true\n}\nexport type PromiseSpawnOptionsBuffer = PromiseSpawnOptions & {\n stdioString: false\n}\nexport type PromiseSpawnOptionsStdin = PromiseSpawnOptions & {\n stdio?:\n | Exclude<IOTypePipe, null>\n | [\n stdin?: IOTypePipe,\n stdout?: Exclude<StdioOptions, IOType>[number],\n stderr?: Exclude<StdioOptions, IOType>[number],\n ]\n}\nexport type PromiseSpawnOptionsNoStdin = PromiseSpawnOptions & {\n stdio:\n | IOTypeNoPipe\n | IOTypeNoPipe[]\n | [\n stdin: IOTypeNoPipe | number,\n stdout?: Exclude<StdioOptions, IOType>[number],\n stderr?: Exclude<StdioOptions, IOType>[number],\n ]\n}\nexport type PromiseSpawnOptionsStdout = PromiseSpawnOptions & {\n stdio?:\n | Exclude<IOTypePipe, null>\n | [\n stdin: Exclude<StdioOptions, IOType>[number] | undefined,\n stdout?: IOTypePipe,\n stderr?: Exclude<StdioOptions, IOType>[number],\n ]\n}\nexport type PromiseSpawnOptionsStdoutString =\n PromiseSpawnOptionsStdout & {\n stdioString?: true\n }\nexport type PromiseSpawnOptionsStdoutBuffer =\n PromiseSpawnOptionsStdout & {\n stdioString: false\n }\nexport type PromiseSpawnOptionsNoStdout = PromiseSpawnOptions & {\n stdio:\n | IOTypeNoPipe\n | IOTypeNoPipe[]\n | [\n stdin: Exclude<StdioOptions, IOType>[number] | undefined,\n stdout?: IOTypeNoPipe,\n stderr?: Exclude<StdioOptions, IOType>[number],\n ]\n}\n/* c8 ignore start - weird windows coverage bug */\nexport type PromiseSpawnOptionsStderr = PromiseSpawnOptions & {\n stdio?:\n | Exclude<IOTypePipe, null>\n | [\n stdin: Exclude<StdioOptions, IOType>[number] | undefined,\n stdout: Exclude<StdioOptions, IOType>[number] | undefined,\n stderr?: IOTypePipe,\n ]\n}\n/* c8 ignore stop */\nexport type PromiseSpawnOptionsStderrString =\n PromiseSpawnOptionsStderr & {\n stdioString?: true\n }\nexport type PromiseSpawnOptionsStderrBuffer =\n PromiseSpawnOptionsStderr & {\n stdioString: false\n }\nexport type PromiseSpawnOptionsNoStderr = PromiseSpawnOptions & {\n stdio:\n | IOTypeNoPipe\n | IOTypeNoPipe[]\n | [\n stdin: Exclude<StdioOptions, IOType>[number] | undefined,\n stdout: Exclude<StdioOptions, IOType>[number] | undefined,\n stderr: IOTypeNoPipe,\n ]\n}\n\nfunction stdioResult<O extends PromiseSpawnOptions>(\n stdout: Buffer[],\n stderr: Buffer[],\n o: O,\n): {\n stdout: SpawnResultByOptions<O>['stdout']\n stderr: SpawnResultByOptions<O>['stderr']\n} {\n return {\n stdout: (!isPipe(o.stdio, 1) ? null\n : o.stdioString !== false ?\n Buffer.concat(stdout).toString().trim()\n : Buffer.concat(stdout)) as SpawnResultByOptions<O>['stdout'],\n stderr: (!isPipe(o.stdio, 2) ? null\n : o.stdioString !== false ?\n Buffer.concat(stderr).toString().trim()\n : Buffer.concat(stderr)) as SpawnResultByOptions<O>['stderr'],\n }\n}\n\nexport type SpawnResult = {\n command: string\n args: string[]\n cwd: string\n status: number | null\n signal: NodeJS.Signals | null\n stdout: Buffer | string | null\n stderr: Buffer | string | null\n}\nexport type SpawnResultString = SpawnResult & {\n stdout: string | null\n stderr: string | null\n}\nexport type SpawnResultBuffer = SpawnResult & {\n stdout: Buffer | null\n stderr: Buffer | null\n}\nexport type SpawnResultStdout = SpawnResult & {\n stdout: Buffer | string\n}\nexport type SpawnResultStdoutString = SpawnResultString & {\n stdout: string\n}\nexport type SpawnResultStdoutBuffer = SpawnResultBuffer & {\n stdout: Buffer\n}\nexport type SpawnResultNoStdout = SpawnResult & {\n stdout: null\n}\nexport type SpawnResultStderr = SpawnResult & {\n stderr: Buffer | string\n}\nexport type SpawnResultStderrString = SpawnResultString & {\n stderr: string\n}\nexport type SpawnResultStderrBuffer = SpawnResultBuffer & {\n stderr: Buffer\n}\nexport type SpawnResultNoStderr = SpawnResult & {\n stderr: null\n}\n\nexport type SpawnResultNoStdio = SpawnResult & {\n stderr: null\n stdout: null\n}\nexport type SpawnResultStdioStrings = SpawnResult & {\n stdout: string\n stderr: string\n}\nexport type SpawnResultStdioBuffers = SpawnResult & {\n stdout: Buffer\n stderr: Buffer\n}\n\nexport type SpawnResultByOptions<T extends PromiseSpawnOptions> =\n SpawnResult & {\n stdout: T extends PromiseSpawnOptionsNoStdout ? null\n : T extends PromiseSpawnOptionsStdoutBuffer ? Buffer\n : T extends PromiseSpawnOptionsStdoutString ? string\n : T extends PromiseSpawnOptionsBuffer ? Buffer | null\n : T extends PromiseSpawnOptionsString ? string | null\n : Buffer | string | null\n stderr: T extends PromiseSpawnOptionsNoStderr ? null\n : T extends PromiseSpawnOptionsStderrBuffer ? Buffer\n : T extends PromiseSpawnOptionsStderrString ? string\n : T extends PromiseSpawnOptionsBuffer ? Buffer | null\n : T extends PromiseSpawnOptionsString ? string | null\n : Buffer | string | null\n }\n\nexport type ChildProcessByOptions<T extends PromiseSpawnOptions> =\n ChildProcess & {\n stdin: T extends PromiseSpawnOptionsNoStdin ? null\n : Exclude<ChildProcess['stdin'], null>\n stdout: T extends PromiseSpawnOptionsNoStdout ? null\n : Exclude<ChildProcess['stdout'], null>\n stderr: T extends PromiseSpawnOptionsNoStderr ? null\n : Exclude<ChildProcess['stderr'], null>\n }\n\n/**\n * Subtype of Promise returned by {@link promiseSpawn}.\n *\n * Resolution value is inferred from the provided options.\n */\nexport class SpawnPromise<\n O extends PromiseSpawnOptions,\n T extends object = object,\n> extends Promise<SpawnResultByOptions<O> & T> {\n [Symbol.toStringTag] = 'SpawnPromise'\n\n /** The spawned process this promise references */\n process!: ChildProcessByOptions<O>\n\n /** Expose the child process stdin, if available */\n stdin!: ChildProcessByOptions<O>['stdin']\n\n /**\n * Set static `Symbol.species` back to the base Promise class so that\n * v8 doesn't get confused by the changed constructor signature.\n */\n static get [Symbol.species]() {\n return Promise\n }\n\n constructor(\n command: string,\n args: string[],\n opts: O,\n extra: T = {} as T,\n ) {\n let proc!: ChildProcessByOptions<O>\n super((res, rej) => {\n proc = spawn(command, args, opts) as ChildProcessByOptions<O>\n const stdout: Buffer[] = []\n const stderr: Buffer[] = []\n const reject = (er: Error) =>\n rej(\n error('command failed', {\n command,\n args,\n cwd: opts.cwd ?? process.cwd(),\n ...stdioResult(stdout, stderr, opts),\n ...extra,\n cause: er,\n }),\n )\n proc.on('error', reject)\n if (proc.stdout) {\n proc.stdout\n .on('data', c => stdout.push(c as Buffer))\n .on('error', er => reject(er))\n }\n if (proc.stderr) {\n proc.stderr\n .on('data', c => stderr.push(c as Buffer))\n .on('error', er => reject(er))\n }\n proc.on('close', (status, signal) => {\n const result = {\n command,\n args,\n cwd: opts.cwd ?? process.cwd(),\n /* c8 ignore next 2 - because windows */\n status: status ?? null,\n signal: signal ?? null,\n ...stdioResult(stdout, stderr, opts),\n ...extra,\n } as SpawnResultByOptions<O> & T\n if ((status || signal) && !opts.acceptFail)\n rej(error('command failed', result))\n else res(result)\n })\n })\n this.process = proc\n this.stdin = proc.stdin\n }\n}\n\n/**\n * Spawn the specified command, and return a promise that resolves when\n * the process closes or has an error.\n */\nexport function promiseSpawn<\n O extends PromiseSpawnOptions = PromiseSpawnOptionsStderrString &\n PromiseSpawnOptionsStdoutString,\n E extends object = object,\n>(command: string, args: string[], opts = {} as O, extra = {} as E) {\n return new SpawnPromise<O, E>(command, args, opts, extra)\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAE3C,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAQ1C,MAAM,MAAM,GAAG,CACb,QAEmB,MAAM,EACzB,EAAU,EACW,EAAE,CACvB,KAAK,KAAK,MAAM,IAAI,KAAK,KAAK,YAAY,IAAI,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI;IACnE,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC9C,CAAC,CAAC,KAAK,CAAA;AAiGT,SAAS,WAAW,CAClB,MAAgB,EAChB,MAAgB,EAChB,CAAI;IAKJ,OAAO;QACL,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI;YACnC,CAAC,CAAC,CAAC,CAAC,WAAW,KAAK,KAAK,CAAC,CAAC;gBACzB,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAA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,EAAE,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAW,CAAC,CAAC;iBAC1C,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAA;YAChC,IAAI,CAAC,MAAM;gBACT,EAAE,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAW,CAAC,CAAC;iBAC1C,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAA;YAChC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,MAAM,GAAG,IAAI,EAAE,MAAM,GAAG,IAAI,EAAE,EAAE;gBAChD,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;oBAC3C,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;gBACnC,CAAC;qBAAM,CAAC;oBACN,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;gBACzB,CAAC;YACH,CAAC,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;QACF,IAAI,CAAC,OAAO,GAAG,IAAI,CAAA;QACnB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAA;IACzB,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAI1B,OAAe,EAAE,IAAc,EAAE,OAAO,EAAO,EAAE,QAAQ,EAAO;IAChE,OAAO,IAAI,YAAY,CAAO,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,CAAA;AAC3D,CAAC","sourcesContent":["import { error } from '@vltpkg/error-cause'\nimport type { ErrorCauseOptions } from '@vltpkg/error-cause'\nimport { spawn } from 'node:child_process'\nimport type {\n ChildProcess,\n IOType,\n SpawnOptions,\n StdioOptions,\n} from 'node:child_process'\n\nconst isPipe = (\n stdio:\n | Exclude<StdioOptions, IOType>[number]\n | StdioOptions = 'pipe',\n fd: number,\n): stdio is IOTypePipe =>\n stdio === 'pipe' || stdio === 'overlapped' || stdio === null ? true\n : Array.isArray(stdio) ? isPipe(stdio[fd], fd)\n : false\n\nexport type IOTypeNoPipe = Exclude<IOType, IOTypePipe>\nexport type IOTypePipe = 'overlapped' | 'pipe' | null | undefined\n\nexport interface PromiseSpawnOptions extends SpawnOptions {\n stdioString?: boolean\n acceptFail?: boolean\n}\nexport interface PromiseSpawnOptionsString\n extends PromiseSpawnOptions {\n stdioString?: true\n}\nexport interface PromiseSpawnOptionsBuffer\n extends PromiseSpawnOptions {\n stdioString: false\n}\nexport interface PromiseSpawnOptionsStdin\n extends PromiseSpawnOptions {\n stdio?:\n | Exclude<IOTypePipe, null>\n | [\n stdin?: IOTypePipe,\n stdout?: Exclude<StdioOptions, IOType>[number],\n stderr?: Exclude<StdioOptions, IOType>[number],\n ]\n}\nexport interface PromiseSpawnOptionsNoStdin\n extends PromiseSpawnOptions {\n stdio:\n | IOTypeNoPipe\n | IOTypeNoPipe[]\n | [\n stdin: IOTypeNoPipe | number,\n stdout?: Exclude<StdioOptions, IOType>[number],\n stderr?: Exclude<StdioOptions, IOType>[number],\n ]\n}\nexport interface PromiseSpawnOptionsStdout\n extends PromiseSpawnOptions {\n stdio?:\n | Exclude<IOTypePipe, null>\n | [\n stdin: Exclude<StdioOptions, IOType>[number] | undefined,\n stdout?: IOTypePipe,\n stderr?: Exclude<StdioOptions, IOType>[number],\n ]\n}\nexport interface PromiseSpawnOptionsStdoutString\n extends PromiseSpawnOptionsStdout {\n stdioString?: true\n}\nexport interface PromiseSpawnOptionsStdoutBuffer\n extends PromiseSpawnOptionsStdout {\n stdioString: false\n}\nexport interface PromiseSpawnOptionsNoStdout\n extends PromiseSpawnOptions {\n stdio:\n | IOTypeNoPipe\n | IOTypeNoPipe[]\n | [\n stdin: Exclude<StdioOptions, IOType>[number] | undefined,\n stdout?: IOTypeNoPipe,\n stderr?: Exclude<StdioOptions, IOType>[number],\n ]\n}\nexport interface PromiseSpawnOptionsStderr\n extends PromiseSpawnOptions {\n stdio?:\n | Exclude<IOTypePipe, null>\n | [\n stdin: Exclude<StdioOptions, IOType>[number] | undefined,\n stdout: Exclude<StdioOptions, IOType>[number] | undefined,\n stderr?: IOTypePipe,\n ]\n}\nexport interface PromiseSpawnOptionsStderrString\n extends PromiseSpawnOptionsStderr {\n stdioString?: true\n}\nexport interface PromiseSpawnOptionsStderrBuffer\n extends PromiseSpawnOptionsStderr {\n stdioString: false\n}\nexport interface PromiseSpawnOptionsNoStderr\n extends PromiseSpawnOptions {\n stdio:\n | IOTypeNoPipe\n | IOTypeNoPipe[]\n | [\n stdin: Exclude<StdioOptions, IOType>[number] | undefined,\n stdout: Exclude<StdioOptions, IOType>[number] | undefined,\n stderr: IOTypeNoPipe,\n ]\n}\n\nfunction stdioResult<O extends PromiseSpawnOptions>(\n stdout: Buffer[],\n stderr: Buffer[],\n o: O,\n): {\n stdout: SpawnResultByOptions<O>['stdout']\n stderr: SpawnResultByOptions<O>['stderr']\n} {\n return {\n stdout: (!isPipe(o.stdio, 1) ? null\n : o.stdioString !== false ?\n Buffer.concat(stdout).toString().trim()\n : Buffer.concat(stdout)) as SpawnResultByOptions<O>['stdout'],\n stderr: (!isPipe(o.stdio, 2) ? null\n : o.stdioString !== false ?\n Buffer.concat(stderr).toString().trim()\n : Buffer.concat(stderr)) as SpawnResultByOptions<O>['stderr'],\n }\n}\n\nexport interface SpawnResult {\n command: string\n args: string[]\n cwd: string\n status: number | null\n signal: NodeJS.Signals | null\n stdout: Buffer | string | null\n stderr: Buffer | string | null\n}\nexport interface SpawnResultString extends SpawnResult {\n stdout: string | null\n stderr: string | null\n}\nexport interface SpawnResultBuffer extends SpawnResult {\n stdout: Buffer | null\n stderr: Buffer | null\n}\nexport interface SpawnResultStdout extends SpawnResult {\n stdout: Buffer | string\n}\nexport interface SpawnResultStdoutString extends SpawnResultString {\n stdout: string\n}\nexport interface SpawnResultStdoutBuffer extends SpawnResultBuffer {\n stdout: Buffer\n}\nexport interface SpawnResultNoStdout extends SpawnResult {\n stdout: null\n}\nexport interface SpawnResultStderr extends SpawnResult {\n stderr: Buffer | string\n}\nexport interface SpawnResultStderrString extends SpawnResultString {\n stderr: string\n}\nexport interface SpawnResultStderrBuffer extends SpawnResultBuffer {\n stderr: Buffer\n}\nexport interface SpawnResultNoStderr extends SpawnResult {\n stderr: null\n}\nexport interface SpawnResultNoStdio extends SpawnResult {\n stderr: null\n stdout: null\n}\nexport interface SpawnResultStdioStrings extends SpawnResult {\n stdout: string\n stderr: string\n}\nexport interface SpawnResultStdioBuffers extends SpawnResult {\n stdout: Buffer\n stderr: Buffer\n}\n\nexport type Override<T, R> = Omit<T, keyof R> & R\n\nexport type SpawnResultByOptions<T extends PromiseSpawnOptions> =\n Override<\n SpawnResult,\n {\n stdout: T extends PromiseSpawnOptionsNoStdout ? null\n : T extends PromiseSpawnOptionsStdoutBuffer ? Buffer\n : T extends PromiseSpawnOptionsStdoutString ? string\n : T extends PromiseSpawnOptionsBuffer ? Buffer | null\n : T extends PromiseSpawnOptionsString ? string | null\n : Buffer | string | null\n stderr: T extends PromiseSpawnOptionsNoStderr ? null\n : T extends PromiseSpawnOptionsStderrBuffer ? Buffer\n : T extends PromiseSpawnOptionsStderrString ? string\n : T extends PromiseSpawnOptionsBuffer ? Buffer | null\n : T extends PromiseSpawnOptionsString ? string | null\n : Buffer | string | null\n }\n >\n\nexport type ChildProcessByOptions<T extends PromiseSpawnOptions> =\n Override<\n ChildProcess,\n {\n stdin: T extends PromiseSpawnOptionsNoStdin ? null\n : Exclude<ChildProcess['stdin'], null>\n stdout: T extends PromiseSpawnOptionsNoStdout ? null\n : Exclude<ChildProcess['stdout'], null>\n stderr: T extends PromiseSpawnOptionsNoStderr ? null\n : Exclude<ChildProcess['stderr'], null>\n }\n >\n\n/**\n * Subtype of Promise returned by {@link promiseSpawn}.\n *\n * Resolution value is inferred from the provided options.\n */\nexport class SpawnPromise<\n O extends PromiseSpawnOptions,\n T extends object = object,\n> extends Promise<SpawnResultByOptions<O> & T> {\n [Symbol.toStringTag] = 'SpawnPromise'\n\n /** The spawned process this promise references */\n process!: ChildProcessByOptions<O>\n\n /** Expose the child process stdin, if available */\n stdin!: ChildProcessByOptions<O>['stdin']\n\n /**\n * Set static `Symbol.species` back to the base Promise class so that\n * v8 doesn't get confused by the changed constructor signature.\n */\n static get [Symbol.species]() {\n return Promise\n }\n\n constructor(\n command: string,\n args: string[],\n opts: O,\n extra: T = {} as T,\n ) {\n let proc!: ChildProcessByOptions<O>\n super((res, rej) => {\n proc = spawn(command, args, opts) as ChildProcessByOptions<O>\n const stdout: Buffer[] = []\n const stderr: Buffer[] = []\n // Don't use the spread operator on successResult or errorResult\n // as that kills any typechecking for the known keys.\n const reject = (\n er?: Error,\n status?: number | null,\n signal?: NodeJS.Signals | null,\n ) => {\n const stdio = stdioResult(stdout, stderr, opts)\n const errorResult: ErrorCauseOptions = {\n command,\n args,\n stdout: stdio.stdout,\n stderr: stdio.stderr,\n cwd: opts.cwd?.toString() ?? process.cwd(),\n }\n if (er !== undefined) {\n errorResult.cause = er\n }\n if (status !== undefined) {\n errorResult.status = status\n }\n if (signal !== undefined) {\n errorResult.signal = signal\n }\n Object.assign(errorResult, extra)\n rej(error('command failed', errorResult))\n }\n const resolve = (\n status: number | null,\n signal: NodeJS.Signals | null,\n ) => {\n const stdio = stdioResult(stdout, stderr, opts)\n const successResult: SpawnResultByOptions<O> = {\n command,\n args,\n status,\n signal,\n stdout: stdio.stdout,\n stderr: stdio.stderr,\n cwd: opts.cwd?.toString() ?? process.cwd(),\n }\n Object.assign(successResult, extra)\n res(successResult as SpawnResultByOptions<O> & T)\n }\n proc.on('error', reject)\n proc.stdout\n ?.on('data', c => stdout.push(c as Buffer))\n .on('error', er => reject(er))\n proc.stderr\n ?.on('data', c => stderr.push(c as Buffer))\n .on('error', er => reject(er))\n proc.on('close', (status = null, signal = null) => {\n if ((status || signal) && !opts.acceptFail) {\n reject(undefined, status, signal)\n } else {\n resolve(status, signal)\n }\n })\n })\n this.process = proc\n this.stdin = proc.stdin\n }\n}\n\n/**\n * Spawn the specified command, and return a promise that resolves when\n * the process closes or has an error.\n */\nexport function promiseSpawn<\n O extends PromiseSpawnOptions = PromiseSpawnOptionsStderrString &\n PromiseSpawnOptionsStdoutString,\n E extends object = object,\n>(command: string, args: string[], opts = {} as O, extra = {} as E) {\n return new SpawnPromise<O, E>(command, args, opts, extra)\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vltpkg/promise-spawn",
|
|
3
3
|
"description": "Spawn a process and return a promise that resolves when it finishes",
|
|
4
|
-
"version": "0.0.0-
|
|
4
|
+
"version": "0.0.0-11",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/vltpkg/vltpkg.git",
|
|
8
|
+
"directory": "src/promise-spawn"
|
|
9
|
+
},
|
|
5
10
|
"tshy": {
|
|
6
11
|
"selfLink": false,
|
|
12
|
+
"liveDev": true,
|
|
7
13
|
"dialects": [
|
|
8
14
|
"esm"
|
|
9
15
|
],
|
|
@@ -13,23 +19,23 @@
|
|
|
13
19
|
}
|
|
14
20
|
},
|
|
15
21
|
"dependencies": {
|
|
16
|
-
"@vltpkg/error-cause": "0.0.0-
|
|
22
|
+
"@vltpkg/error-cause": "0.0.0-11"
|
|
17
23
|
},
|
|
18
24
|
"devDependencies": {
|
|
19
|
-
"@eslint/js": "^9.
|
|
20
|
-
"@types/
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"prettier": "^3.3.2",
|
|
25
|
+
"@eslint/js": "^9.25.1",
|
|
26
|
+
"@types/node": "^22.15.3",
|
|
27
|
+
"eslint": "^9.25.1",
|
|
28
|
+
"prettier": "^3.5.3",
|
|
24
29
|
"spawk": "^1.8.2",
|
|
25
|
-
"tap": "^21.0
|
|
30
|
+
"tap": "^21.1.0",
|
|
26
31
|
"tshy": "^3.0.2",
|
|
27
|
-
"
|
|
28
|
-
"typescript
|
|
32
|
+
"typedoc": "~0.27.9",
|
|
33
|
+
"typescript": "5.7.3",
|
|
34
|
+
"typescript-eslint": "^8.31.1"
|
|
29
35
|
},
|
|
30
36
|
"license": "ISC",
|
|
31
37
|
"engines": {
|
|
32
|
-
"node": "
|
|
38
|
+
"node": ">=22"
|
|
33
39
|
},
|
|
34
40
|
"tap": {
|
|
35
41
|
"extends": "../../tap-config.yaml"
|
|
@@ -54,9 +60,10 @@
|
|
|
54
60
|
"format:check": "prettier --check . --ignore-path ../../.prettierignore --cache",
|
|
55
61
|
"lint": "eslint . --fix",
|
|
56
62
|
"lint:check": "eslint .",
|
|
57
|
-
"presnap": "tshy",
|
|
58
63
|
"snap": "tap",
|
|
59
|
-
"
|
|
60
|
-
"
|
|
64
|
+
"test": "tap",
|
|
65
|
+
"posttest": "tsc --noEmit",
|
|
66
|
+
"tshy": "tshy",
|
|
67
|
+
"typecheck": "tsc --noEmit"
|
|
61
68
|
}
|
|
62
69
|
}
|