@vltpkg/promise-spawn 0.0.0-0.1730239248325

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/LICENSE ADDED
@@ -0,0 +1,16 @@
1
+ The ISC License
2
+
3
+ Copyright (c) npm, Inc.
4
+ Copyright (c) vlt technology, Inc.
5
+
6
+ Permission to use, copy, modify, and/or distribute this software for any
7
+ purpose with or without fee is hereby granted, provided that the above
8
+ copyright notice and this permission notice appear in all copies.
9
+
10
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE NPM DISCLAIMS ALL WARRANTIES WITH
11
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
12
+ FITNESS. IN NO EVENT SHALL THE NPM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT,
13
+ OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
14
+ DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
15
+ ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
16
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,123 @@
1
+ # `@vltpkg/promise-spawn`
2
+
3
+ Spawn a process and return a promise that resolves when the
4
+ process closes. Fork of
5
+ [`@npmcli/promise-spawn`](http://npm.im/@npmcli/promise-spawn)
6
+
7
+ ## Differences from `@npmcli/promise-spawn`
8
+
9
+ - A `SpawnPromise(cmd, args, options)` class is added that
10
+ handles most of the functionality.
11
+ - `promiseSpawn.open()` is removed
12
+ - When run as root, it just runs the command as root, it doesn't
13
+ try to infer the uid/gid based on the owner of the cwd..
14
+ - No special handling for `shell: true` processes, and thus, no
15
+ escaping of arguments in that case. (It's just passed through
16
+ to Node's `spawn()` method.)
17
+ - Fully type-aware, even down to inferring the presence and type
18
+ of `stdout` and `stderr` properties, as well as the properties
19
+ added via the optional `extra` argument.
20
+
21
+ ## USAGE
22
+
23
+ ```js
24
+ import { promiseSpawn, SpawnPromise } from '@vltpkg/promise-spawn'
25
+
26
+ promiseSpawn(
27
+ 'ls',
28
+ ['-laF', 'some/dir/*.js'],
29
+ {
30
+ cwd: '/tmp/some/path', // defaults to process.cwd()
31
+ stdioString: true, // stdout/stderr as strings rather than buffers
32
+ stdio: 'pipe', // any node spawn stdio arg is valid here
33
+ // any other arguments to node child_process.spawn can go here as well,
34
+ },
35
+ {
36
+ extra: 'things',
37
+ to: 'decorate',
38
+ the: 'result',
39
+ },
40
+ )
41
+ .then(result => {
42
+ // {status === 0, signal === null, stdout, stderr, and all the extras}
43
+ console.log('ok!', result)
44
+ })
45
+ .catch(er => {
46
+ // er has all the same properties as the result, set appropriately
47
+ console.error('failed!', er)
48
+ })
49
+ ```
50
+
51
+ ## API
52
+
53
+ ### `promiseSpawn(cmd, args, opts, extra)` -> `Promise`
54
+
55
+ Run the command, return a Promise that resolves/rejects based on the
56
+ process result.
57
+
58
+ Result or error will be decorated with the properties in the `extra`
59
+ object. You can use this to attach some helpful info about _why_ the
60
+ command is being run, if it makes sense for your use case.
61
+
62
+ If `stdio` is set to anything other than `'inherit'`, then the result/error
63
+ will be decorated with `stdout` and `stderr` values. If `stdioString` is
64
+ set to `true`, these will be strings. Otherwise they will be Buffer
65
+ objects.
66
+
67
+ Returned promise is decorated with the `stdin` stream if the process is set
68
+ to pipe from `stdin`. Writing to this stream writes to the `stdin` of the
69
+ spawned process.
70
+
71
+ #### Options
72
+
73
+ - `stdioString` Boolean, default `true`. Return stdout/stderr
74
+ output as trimmed strings rather than buffers.
75
+ - `acceptFail` Boolean, default `false`. If true, then a process
76
+ that closes with `status` other than 0, or `signal` other than
77
+ `null`, will reject the promise. If true, then failure exits
78
+ resolve the promise normally. This is useful when you need to
79
+ run a process where an exit status of `>0` is informative, to
80
+ avoid creating an Error object for it.
81
+ - Any other options for `child_process.spawn` can be passed as
82
+ well.
83
+
84
+ ## TypeScript Inference Caveat (and workaround)
85
+
86
+ If you provide a complex stdio option like `['pipe', 'inherit']`,
87
+ then this will of course mean that `stdin` is set to a writable
88
+ stream, `stderr` is set to a readable stream (because that's the
89
+ default), but `stdout` is set to `null`.
90
+
91
+ The types will accurately infer this from the type of the
92
+ argument. However, observe this incorrect result:
93
+
94
+ ```
95
+ const result = await promiseSpawn(cmd, args, {
96
+ stdio: ['pipe', 'inherit'],
97
+ })
98
+ result.stdout
99
+ // ^? string <-- WRONG
100
+ result.stderr
101
+ // ^? string
102
+ ```
103
+
104
+ TS will infer the `options.stdio` property to be `('pipe' |
105
+ 'inherit')[]`. Since the second item of such an array _might_ be
106
+ set to `'pipe'` at some point, TS will infer the return value to
107
+ include `{ stdout: string }`.
108
+
109
+ To get around this, typecast the field to its literal value. This
110
+ is a bit noisy, but works fine:
111
+
112
+ ```js
113
+ const result = await promiseSpawn(cmd, args, {
114
+ stdio: ['pipe', 'inherit'] as ['pipe', 'inherit'],
115
+ })
116
+ result.stdout
117
+ // ^? null <-- CORRECT!
118
+ result.stderr
119
+ // ^? string
120
+ ```
121
+
122
+ When given a single argument to apply to all `stdio` fields, this
123
+ inference happens correctly by default.
@@ -0,0 +1,153 @@
1
+ import { ChildProcess, IOType, SpawnOptions, StdioOptions } from 'child_process';
2
+ export type IOTypeNoPipe = Exclude<IOType, IOTypePipe>;
3
+ export type IOTypePipe = 'overlapped' | 'pipe' | null | undefined;
4
+ export type PromiseSpawnOptions = SpawnOptions & {
5
+ stdioString?: boolean;
6
+ acceptFail?: boolean;
7
+ };
8
+ export type PromiseSpawnOptionsString = PromiseSpawnOptions & {
9
+ stdioString?: true;
10
+ };
11
+ export type PromiseSpawnOptionsBuffer = PromiseSpawnOptions & {
12
+ stdioString: false;
13
+ };
14
+ export type PromiseSpawnOptionsStdin = PromiseSpawnOptions & {
15
+ stdio?: Exclude<IOTypePipe, null> | [
16
+ stdin?: IOTypePipe,
17
+ stdout?: Exclude<StdioOptions, IOType>[number],
18
+ stderr?: Exclude<StdioOptions, IOType>[number]
19
+ ];
20
+ };
21
+ export type PromiseSpawnOptionsNoStdin = PromiseSpawnOptions & {
22
+ stdio: IOTypeNoPipe | IOTypeNoPipe[] | [
23
+ stdin: IOTypeNoPipe | number,
24
+ stdout?: Exclude<StdioOptions, IOType>[number],
25
+ stderr?: Exclude<StdioOptions, IOType>[number]
26
+ ];
27
+ };
28
+ export type PromiseSpawnOptionsStdout = PromiseSpawnOptions & {
29
+ stdio?: Exclude<IOTypePipe, null> | [
30
+ stdin: Exclude<StdioOptions, IOType>[number] | undefined,
31
+ stdout?: IOTypePipe,
32
+ stderr?: Exclude<StdioOptions, IOType>[number]
33
+ ];
34
+ };
35
+ export type PromiseSpawnOptionsStdoutString = PromiseSpawnOptionsStdout & {
36
+ stdioString?: true;
37
+ };
38
+ export type PromiseSpawnOptionsStdoutBuffer = PromiseSpawnOptionsStdout & {
39
+ stdioString: false;
40
+ };
41
+ export type PromiseSpawnOptionsNoStdout = PromiseSpawnOptions & {
42
+ stdio: IOTypeNoPipe | IOTypeNoPipe[] | [
43
+ stdin: Exclude<StdioOptions, IOType>[number] | undefined,
44
+ stdout?: IOTypeNoPipe,
45
+ stderr?: Exclude<StdioOptions, IOType>[number]
46
+ ];
47
+ };
48
+ export type PromiseSpawnOptionsStderr = PromiseSpawnOptions & {
49
+ stdio?: Exclude<IOTypePipe, null> | [
50
+ stdin: Exclude<StdioOptions, IOType>[number] | undefined,
51
+ stdout: Exclude<StdioOptions, IOType>[number] | undefined,
52
+ stderr?: IOTypePipe
53
+ ];
54
+ };
55
+ export type PromiseSpawnOptionsStderrString = PromiseSpawnOptionsStderr & {
56
+ stdioString?: true;
57
+ };
58
+ export type PromiseSpawnOptionsStderrBuffer = PromiseSpawnOptionsStderr & {
59
+ stdioString: false;
60
+ };
61
+ export type PromiseSpawnOptionsNoStderr = PromiseSpawnOptions & {
62
+ stdio: IOTypeNoPipe | IOTypeNoPipe[] | [
63
+ stdin: Exclude<StdioOptions, IOType>[number] | undefined,
64
+ stdout: Exclude<StdioOptions, IOType>[number] | undefined,
65
+ stderr: IOTypeNoPipe
66
+ ];
67
+ };
68
+ export type SpawnResult = {
69
+ command: string;
70
+ args: string[];
71
+ cwd: string;
72
+ status: number | null;
73
+ signal: NodeJS.Signals | null;
74
+ stdout: Buffer | string | null;
75
+ stderr: Buffer | string | null;
76
+ };
77
+ export type SpawnResultString = SpawnResult & {
78
+ stdout: string | null;
79
+ stderr: string | null;
80
+ };
81
+ export type SpawnResultBuffer = SpawnResult & {
82
+ stdout: Buffer | null;
83
+ stderr: Buffer | null;
84
+ };
85
+ export type SpawnResultStdout = SpawnResult & {
86
+ stdout: Buffer | string;
87
+ };
88
+ export type SpawnResultStdoutString = SpawnResultString & {
89
+ stdout: string;
90
+ };
91
+ export type SpawnResultStdoutBuffer = SpawnResultBuffer & {
92
+ stdout: Buffer;
93
+ };
94
+ export type SpawnResultNoStdout = SpawnResult & {
95
+ stdout: null;
96
+ };
97
+ export type SpawnResultStderr = SpawnResult & {
98
+ stderr: Buffer | string;
99
+ };
100
+ export type SpawnResultStderrString = SpawnResultString & {
101
+ stderr: string;
102
+ };
103
+ export type SpawnResultStderrBuffer = SpawnResultBuffer & {
104
+ stderr: Buffer;
105
+ };
106
+ export type SpawnResultNoStderr = SpawnResult & {
107
+ stderr: null;
108
+ };
109
+ export type SpawnResultNoStdio = SpawnResult & {
110
+ stderr: null;
111
+ stdout: null;
112
+ };
113
+ export type SpawnResultStdioStrings = SpawnResult & {
114
+ stdout: string;
115
+ stderr: string;
116
+ };
117
+ export type SpawnResultStdioBuffers = SpawnResult & {
118
+ stdout: Buffer;
119
+ stderr: Buffer;
120
+ };
121
+ export type SpawnResultByOptions<T extends PromiseSpawnOptions> = SpawnResult & {
122
+ 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
+ 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 & {
126
+ stdin: T extends PromiseSpawnOptionsNoStdin ? null : Exclude<ChildProcess['stdin'], null>;
127
+ stdout: T extends PromiseSpawnOptionsNoStdout ? null : Exclude<ChildProcess['stdout'], null>;
128
+ stderr: T extends PromiseSpawnOptionsNoStderr ? null : Exclude<ChildProcess['stderr'], null>;
129
+ };
130
+ /**
131
+ * Subtype of Promise returned by {@link spawnPromise}.
132
+ *
133
+ * Resolution value is inferred from the provided options.
134
+ */
135
+ export declare class SpawnPromise<O extends PromiseSpawnOptions, T extends object = object> extends Promise<SpawnResultByOptions<O> & T> {
136
+ [Symbol.toStringTag]: string;
137
+ /** The spawned process this promise references */
138
+ process: ChildProcessByOptions<O>;
139
+ /** Expose the child process stdin, if available */
140
+ stdin: ChildProcessByOptions<O>['stdin'];
141
+ /**
142
+ * Set static `Symbol.species` back to the base Promise class so that
143
+ * v8 doesn't get confused by the changed constructor signature.
144
+ */
145
+ static get [Symbol.species](): PromiseConstructor;
146
+ constructor(command: string, args: string[], opts: O, extra?: T);
147
+ }
148
+ /**
149
+ * Spawn the specified command, and return a promise that resolves when
150
+ * the process closes or has an error.
151
+ */
152
+ export declare function promiseSpawn<O extends PromiseSpawnOptions = PromiseSpawnOptionsStderrString & PromiseSpawnOptionsStdoutString, E extends object = object>(command: string, args: string[], opts?: O, extra?: E): SpawnPromise<O, E>;
153
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,YAAY,EACZ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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"}
@@ -0,0 +1,89 @@
1
+ import { error } from '@vltpkg/error-cause';
2
+ import { spawn, } from 'child_process';
3
+ const isPipe = (stdio = 'pipe', fd) => stdio === 'pipe' || stdio === 'overlapped' || stdio === null ? true
4
+ : Array.isArray(stdio) ? isPipe(stdio[fd], fd)
5
+ : false;
6
+ function stdioResult(stdout, stderr, o) {
7
+ return {
8
+ stdout: (!isPipe(o.stdio, 1) ? null
9
+ : o.stdioString !== false ?
10
+ Buffer.concat(stdout).toString().trim()
11
+ : Buffer.concat(stdout)),
12
+ stderr: (!isPipe(o.stdio, 2) ? null
13
+ : o.stdioString !== false ?
14
+ Buffer.concat(stderr).toString().trim()
15
+ : Buffer.concat(stderr)),
16
+ };
17
+ }
18
+ /**
19
+ * Subtype of Promise returned by {@link spawnPromise}.
20
+ *
21
+ * Resolution value is inferred from the provided options.
22
+ */
23
+ export class SpawnPromise extends Promise {
24
+ [Symbol.toStringTag] = 'SpawnPromise';
25
+ /** The spawned process this promise references */
26
+ process;
27
+ /** Expose the child process stdin, if available */
28
+ stdin;
29
+ /**
30
+ * Set static `Symbol.species` back to the base Promise class so that
31
+ * v8 doesn't get confused by the changed constructor signature.
32
+ */
33
+ static get [Symbol.species]() {
34
+ return Promise;
35
+ }
36
+ constructor(command, args, opts, extra = {}) {
37
+ let proc;
38
+ super((res, rej) => {
39
+ proc = spawn(command, args, opts);
40
+ const stdout = [];
41
+ const stderr = [];
42
+ const reject = (er) => rej(error('command failed', {
43
+ command,
44
+ args,
45
+ cwd: opts.cwd ?? process.cwd(),
46
+ ...stdioResult(stdout, stderr, opts),
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 = {
63
+ command,
64
+ args,
65
+ cwd: opts.cwd ?? process.cwd(),
66
+ /* c8 ignore next 2 - because windows */
67
+ status: status ?? null,
68
+ signal: signal ?? null,
69
+ ...stdioResult(stdout, stderr, opts),
70
+ ...extra,
71
+ };
72
+ if ((status || signal) && !opts.acceptFail)
73
+ rej(error('command failed', result));
74
+ else
75
+ res(result);
76
+ });
77
+ });
78
+ this.process = proc;
79
+ this.stdin = proc.stdin;
80
+ }
81
+ }
82
+ /**
83
+ * Spawn the specified command, and return a promise that resolves when
84
+ * the process closes or has an error.
85
+ */
86
+ export function promiseSpawn(command, args, opts = {}, extra = {}) {
87
+ return new SpawnPromise(command, args, opts, extra);
88
+ }
89
+ //# sourceMappingURL=index.js.map
@@ -0,0 +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,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CAAC,IAAI,CAAC,IAAI,CAAC,UAAU;oBACxC,GAAG,CAAC,KAAK,CAAC,gBAAgB,EAAE,MAAM,CAAC,CAAC,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 ChildProcess,\n IOType,\n spawn,\n SpawnOptions,\n 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 spawnPromise}.\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))\n .on('error', er => reject(er))\n }\n if (proc.stderr) {\n proc.stderr\n .on('data', c => stderr.push(c))\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"]}
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "module"
3
+ }
package/package.json ADDED
@@ -0,0 +1,62 @@
1
+ {
2
+ "name": "@vltpkg/promise-spawn",
3
+ "description": "Spawn a process and return a promise that resolves when it finishes",
4
+ "version": "0.0.0-0.1730239248325",
5
+ "tshy": {
6
+ "selfLink": false,
7
+ "dialects": [
8
+ "esm"
9
+ ],
10
+ "exports": {
11
+ "./package.json": "./package.json",
12
+ ".": "./src/index.ts"
13
+ }
14
+ },
15
+ "dependencies": {
16
+ "@vltpkg/error-cause": "0.0.0-0.1730239248325"
17
+ },
18
+ "devDependencies": {
19
+ "@eslint/js": "^9.8.0",
20
+ "@types/eslint__js": "^8.42.3",
21
+ "@types/node": "^22.4.1",
22
+ "eslint": "^9.8.0",
23
+ "prettier": "^3.3.2",
24
+ "spawk": "^1.8.2",
25
+ "tap": "^21.0.1",
26
+ "tshy": "^3.0.2",
27
+ "typescript": "^5.5.4",
28
+ "typescript-eslint": "^8.0.1"
29
+ },
30
+ "license": "ISC",
31
+ "engines": {
32
+ "node": "20 || >=22"
33
+ },
34
+ "tap": {
35
+ "extends": "../../tap-config.yaml"
36
+ },
37
+ "prettier": "../../.prettierrc.js",
38
+ "module": "./dist/esm/index.js",
39
+ "type": "module",
40
+ "exports": {
41
+ "./package.json": "./package.json",
42
+ ".": {
43
+ "import": {
44
+ "types": "./dist/esm/index.d.ts",
45
+ "default": "./dist/esm/index.js"
46
+ }
47
+ }
48
+ },
49
+ "files": [
50
+ "dist"
51
+ ],
52
+ "scripts": {
53
+ "format": "prettier --write . --log-level warn --ignore-path ../../.prettierignore --cache",
54
+ "format:check": "prettier --check . --ignore-path ../../.prettierignore --cache",
55
+ "lint": "eslint . --fix",
56
+ "lint:check": "eslint .",
57
+ "presnap": "tshy",
58
+ "snap": "tap",
59
+ "pretest": "tshy",
60
+ "test": "tap"
61
+ }
62
+ }