@vltpkg/promise-spawn 0.0.0-0.1730724342581 → 0.0.0-2

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.
@@ -1,71 +1,71 @@
1
- import { type ChildProcess, type IOType, type SpawnOptions, type StdioOptions } from 'child_process';
1
+ import type { ChildProcess, IOType, SpawnOptions, StdioOptions } from 'child_process';
2
2
  export type IOTypeNoPipe = Exclude<IOType, IOTypePipe>;
3
3
  export type IOTypePipe = 'overlapped' | 'pipe' | null | undefined;
4
- export type PromiseSpawnOptions = SpawnOptions & {
4
+ export interface PromiseSpawnOptions extends SpawnOptions {
5
5
  stdioString?: boolean;
6
6
  acceptFail?: boolean;
7
- };
8
- export type PromiseSpawnOptionsString = PromiseSpawnOptions & {
7
+ }
8
+ export interface PromiseSpawnOptionsString extends PromiseSpawnOptions {
9
9
  stdioString?: true;
10
- };
11
- export type PromiseSpawnOptionsBuffer = PromiseSpawnOptions & {
10
+ }
11
+ export interface PromiseSpawnOptionsBuffer extends PromiseSpawnOptions {
12
12
  stdioString: false;
13
- };
14
- export type PromiseSpawnOptionsStdin = PromiseSpawnOptions & {
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 type PromiseSpawnOptionsNoStdin = PromiseSpawnOptions & {
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 type PromiseSpawnOptionsStdout = PromiseSpawnOptions & {
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 type PromiseSpawnOptionsStdoutString = PromiseSpawnOptionsStdout & {
34
+ }
35
+ export interface PromiseSpawnOptionsStdoutString extends PromiseSpawnOptionsStdout {
36
36
  stdioString?: true;
37
- };
38
- export type PromiseSpawnOptionsStdoutBuffer = PromiseSpawnOptionsStdout & {
37
+ }
38
+ export interface PromiseSpawnOptionsStdoutBuffer extends PromiseSpawnOptionsStdout {
39
39
  stdioString: false;
40
- };
41
- export type PromiseSpawnOptionsNoStdout = PromiseSpawnOptions & {
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 type PromiseSpawnOptionsStderr = PromiseSpawnOptions & {
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 type PromiseSpawnOptionsStderrString = PromiseSpawnOptionsStderr & {
54
+ }
55
+ export interface PromiseSpawnOptionsStderrString extends PromiseSpawnOptionsStderr {
56
56
  stdioString?: true;
57
- };
58
- export type PromiseSpawnOptionsStderrBuffer = PromiseSpawnOptionsStderr & {
57
+ }
58
+ export interface PromiseSpawnOptionsStderrBuffer extends PromiseSpawnOptionsStderr {
59
59
  stdioString: false;
60
- };
61
- export type PromiseSpawnOptionsNoStderr = PromiseSpawnOptions & {
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 type SpawnResult = {
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 type SpawnResultString = SpawnResult & {
76
+ }
77
+ export interface SpawnResultString extends SpawnResult {
78
78
  stdout: string | null;
79
79
  stderr: string | null;
80
- };
81
- export type SpawnResultBuffer = SpawnResult & {
80
+ }
81
+ export interface SpawnResultBuffer extends SpawnResult {
82
82
  stdout: Buffer | null;
83
83
  stderr: Buffer | null;
84
- };
85
- export type SpawnResultStdout = SpawnResult & {
84
+ }
85
+ export interface SpawnResultStdout extends SpawnResult {
86
86
  stdout: Buffer | string;
87
- };
88
- export type SpawnResultStdoutString = SpawnResultString & {
87
+ }
88
+ export interface SpawnResultStdoutString extends SpawnResultString {
89
89
  stdout: string;
90
- };
91
- export type SpawnResultStdoutBuffer = SpawnResultBuffer & {
90
+ }
91
+ export interface SpawnResultStdoutBuffer extends SpawnResultBuffer {
92
92
  stdout: Buffer;
93
- };
94
- export type SpawnResultNoStdout = SpawnResult & {
93
+ }
94
+ export interface SpawnResultNoStdout extends SpawnResult {
95
95
  stdout: null;
96
- };
97
- export type SpawnResultStderr = SpawnResult & {
96
+ }
97
+ export interface SpawnResultStderr extends SpawnResult {
98
98
  stderr: Buffer | string;
99
- };
100
- export type SpawnResultStderrString = SpawnResultString & {
99
+ }
100
+ export interface SpawnResultStderrString extends SpawnResultString {
101
101
  stderr: string;
102
- };
103
- export type SpawnResultStderrBuffer = SpawnResultBuffer & {
102
+ }
103
+ export interface SpawnResultStderrBuffer extends SpawnResultBuffer {
104
104
  stderr: Buffer;
105
- };
106
- export type SpawnResultNoStderr = SpawnResult & {
105
+ }
106
+ export interface SpawnResultNoStderr extends SpawnResult {
107
107
  stderr: null;
108
- };
109
- export type SpawnResultNoStdio = SpawnResult & {
108
+ }
109
+ export interface SpawnResultNoStdio extends SpawnResult {
110
110
  stderr: null;
111
111
  stdout: null;
112
- };
113
- export type SpawnResultStdioStrings = SpawnResult & {
112
+ }
113
+ export interface SpawnResultStdioStrings extends SpawnResult {
114
114
  stdout: string;
115
115
  stderr: string;
116
- };
117
- export type SpawnResultStdioBuffers = SpawnResult & {
116
+ }
117
+ export interface SpawnResultStdioBuffers extends SpawnResult {
118
118
  stdout: Buffer;
119
119
  stderr: Buffer;
120
- };
121
- export type SpawnResultByOptions<T extends PromiseSpawnOptions> = SpawnResult & {
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
  *
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,MAAM,EAEX,KAAK,YAAY,EACjB,KAAK,YAAY,EAClB,MAAM,eAAe,CAAA;AAYtB,MAAM,MAAM,YAAY,GAAG,OAAO,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;AACtD,MAAM,MAAM,UAAU,GAAG,YAAY,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;AACjE,MAAM,MAAM,mBAAmB,GAAG,YAAY,GAAG;IAC/C,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB,CAAA;AACD,MAAM,MAAM,yBAAyB,GAAG,mBAAmB,GAAG;IAC5D,WAAW,CAAC,EAAE,IAAI,CAAA;CACnB,CAAA;AACD,MAAM,MAAM,yBAAyB,GAAG,mBAAmB,GAAG;IAC5D,WAAW,EAAE,KAAK,CAAA;CACnB,CAAA;AACD,MAAM,MAAM,wBAAwB,GAAG,mBAAmB,GAAG;IAC3D,KAAK,CAAC,EACF,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC,GACzB;QACE,KAAK,CAAC,EAAE,UAAU;QAClB,MAAM,CAAC,EAAE,OAAO,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC;QAC9C,MAAM,CAAC,EAAE,OAAO,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC;KAC/C,CAAA;CACN,CAAA;AACD,MAAM,MAAM,0BAA0B,GAAG,mBAAmB,GAAG;IAC7D,KAA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AAkD;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;CAgDrB;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, } from 'child_process';
2
+ import { spawn } from '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;
@@ -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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AI,IAAI;oBACtB,MAAM,EAAE,MAAM,IAAI,IAAI;oBACtB,GAAG,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC;oBACpC,GAAG,KAAK;iBACsB,CAAA;gBAChC,IAAI,CAAC,MAAM,IAAI,MAAM,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 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;AAC3C,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAQrC,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,WAA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AAM,EAAE,MAAM,EAAE,IAAI,CAAC;oBACpC,GAAG,KAAK;iBACsB,CAAA;gBAChC,IAAI,CAAC,MAAM,IAAI,MAAM,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 { spawn } from 'child_process'\nimport type {\n ChildProcess,\n IOType,\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\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 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"]}
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-0.1730724342581",
4
+ "version": "0.0.0-2",
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,24 @@
13
19
  }
14
20
  },
15
21
  "dependencies": {
16
- "@vltpkg/error-cause": "0.0.0-0.1730724342581"
22
+ "@vltpkg/error-cause": "0.0.0-2"
17
23
  },
18
24
  "devDependencies": {
19
- "@eslint/js": "^9.8.0",
25
+ "@eslint/js": "^9.20.0",
20
26
  "@types/eslint__js": "^8.42.3",
21
- "@types/node": "^22.4.1",
22
- "eslint": "^9.8.0",
23
- "prettier": "^3.3.2",
27
+ "@types/node": "^22.13.1",
28
+ "eslint": "^9.20.0",
29
+ "prettier": "^3.4.2",
24
30
  "spawk": "^1.8.2",
25
- "tap": "^21.0.1",
31
+ "tap": "^21.1.0",
26
32
  "tshy": "^3.0.2",
27
- "typescript": "^5.5.4",
28
- "typescript-eslint": "^8.0.1"
33
+ "typedoc": "0.27.6",
34
+ "typescript": "5.7.3",
35
+ "typescript-eslint": "^8.23.0"
29
36
  },
30
37
  "license": "ISC",
31
38
  "engines": {
32
- "node": "20 || >=22"
39
+ "node": ">=22"
33
40
  },
34
41
  "tap": {
35
42
  "extends": "../../tap-config.yaml"
@@ -54,9 +61,9 @@
54
61
  "format:check": "prettier --check . --ignore-path ../../.prettierignore --cache",
55
62
  "lint": "eslint . --fix",
56
63
  "lint:check": "eslint .",
57
- "presnap": "tshy",
58
64
  "snap": "tap",
59
- "pretest": "tshy",
60
- "test": "tap"
65
+ "test": "tap",
66
+ "posttest": "tsc --noEmit",
67
+ "typecheck": "tsc --noEmit"
61
68
  }
62
69
  }