soda-nodejs 0.4.2 → 0.4.3

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,22 +1,27 @@
1
1
  /// <reference types="node" />
2
- import { SpawnOptions, SpawnOptionsWithStdioTuple, SpawnOptionsWithoutStdio, StdioNull, StdioPipe } from "child_process";
3
- export declare function spawnAsync(command: string, options?: SpawnOptionsWithoutStdio): Promise<void>;
4
- export declare function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe>): Promise<void>;
5
- export declare function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioNull>): Promise<void>;
6
- export declare function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioPipe>): Promise<void>;
7
- export declare function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>): Promise<void>;
8
- export declare function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioNull>): Promise<void>;
9
- export declare function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioNull>): Promise<void>;
10
- export declare function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioPipe>): Promise<void>;
11
- export declare function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioNull>): Promise<void>;
12
- export declare function spawnAsync(command: string, options: SpawnOptions): Promise<void>;
13
- export declare function spawnAsync(command: string, args?: readonly string[], options?: SpawnOptionsWithoutStdio): Promise<void>;
14
- export declare function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe>): Promise<void>;
15
- export declare function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioNull>): Promise<void>;
16
- export declare function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioPipe>): Promise<void>;
17
- export declare function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>): Promise<void>;
18
- export declare function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioNull>): Promise<void>;
19
- export declare function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioNull>): Promise<void>;
20
- export declare function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioPipe>): Promise<void>;
21
- export declare function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioNull>): Promise<void>;
22
- export declare function spawnAsync(command: string, args: readonly string[], options: SpawnOptions): Promise<void>;
2
+ /// <reference types="node" />
3
+ import { ChildProcess, ChildProcessByStdio, ChildProcessWithoutNullStreams, SpawnOptions, SpawnOptionsWithStdioTuple, SpawnOptionsWithoutStdio, StdioNull, StdioPipe } from "child_process";
4
+ import { Readable, Writable } from "stream";
5
+ export interface PromiseWithChildProcess<T> extends Promise<T> {
6
+ child: T;
7
+ }
8
+ export declare function spawnAsync(command: string, options?: SpawnOptionsWithoutStdio): PromiseWithChildProcess<ChildProcessWithoutNullStreams>;
9
+ export declare function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe>): PromiseWithChildProcess<ChildProcessByStdio<Writable, Readable, Readable>>;
10
+ export declare function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioNull>): PromiseWithChildProcess<ChildProcessByStdio<Writable, Readable, null>>;
11
+ export declare function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioPipe>): PromiseWithChildProcess<ChildProcessByStdio<Writable, null, Readable>>;
12
+ export declare function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>): PromiseWithChildProcess<ChildProcessByStdio<null, Readable, Readable>>;
13
+ export declare function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioNull>): PromiseWithChildProcess<ChildProcessByStdio<Writable, null, null>>;
14
+ export declare function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioNull>): PromiseWithChildProcess<ChildProcessByStdio<null, Readable, null>>;
15
+ export declare function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioPipe>): PromiseWithChildProcess<ChildProcessByStdio<null, null, Readable>>;
16
+ export declare function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioNull>): PromiseWithChildProcess<ChildProcessByStdio<null, null, null>>;
17
+ export declare function spawnAsync(command: string, options: SpawnOptions): PromiseWithChildProcess<ChildProcess>;
18
+ export declare function spawnAsync(command: string, args?: readonly string[], options?: SpawnOptionsWithoutStdio): PromiseWithChildProcess<ChildProcessWithoutNullStreams>;
19
+ export declare function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe>): PromiseWithChildProcess<ChildProcessByStdio<Writable, Readable, Readable>>;
20
+ export declare function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioNull>): PromiseWithChildProcess<ChildProcessByStdio<Writable, Readable, null>>;
21
+ export declare function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioPipe>): PromiseWithChildProcess<ChildProcessByStdio<Writable, null, Readable>>;
22
+ export declare function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>): PromiseWithChildProcess<ChildProcessByStdio<null, Readable, Readable>>;
23
+ export declare function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioNull>): PromiseWithChildProcess<ChildProcessByStdio<Writable, null, null>>;
24
+ export declare function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioNull>): PromiseWithChildProcess<ChildProcessByStdio<null, Readable, null>>;
25
+ export declare function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioPipe>): PromiseWithChildProcess<ChildProcessByStdio<null, null, Readable>>;
26
+ export declare function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioNull>): PromiseWithChildProcess<ChildProcessByStdio<null, null, null>>;
27
+ export declare function spawnAsync(command: string, args: readonly string[], options: SpawnOptions): PromiseWithChildProcess<ChildProcess>;
@@ -23,17 +23,19 @@ __export(spawnAsync_exports, {
23
23
  });
24
24
  module.exports = __toCommonJS(spawnAsync_exports);
25
25
  var import_child_process = require("child_process");
26
- async function spawnAsync(command, args, options) {
27
- await new Promise((resolve, reject) => {
26
+ function spawnAsync(command, args, options) {
27
+ const promise = new Promise((resolve, reject) => {
28
28
  const child = (0, import_child_process.spawn)(command, args, options);
29
+ promise.child = child;
29
30
  child.on("exit", (code) => {
30
- if (code !== 0) {
31
- reject(new Error(`"${command}" Command failed with code ${code}`));
32
- return;
33
- }
34
- resolve();
31
+ if (code === 0)
32
+ return resolve(child);
33
+ console.error(`"${command}" Command failed with code ${code}`);
34
+ reject(new Error(`"${command}" Command failed with code ${code}`));
35
+ return;
35
36
  });
36
37
  });
38
+ return promise;
37
39
  }
38
40
  // Annotate the CommonJS export names for ESM import in node:
39
41
  0 && (module.exports = {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/utils/spawnAsync.ts"],
4
- "sourcesContent": ["import { SpawnOptions, SpawnOptionsWithStdioTuple, SpawnOptionsWithoutStdio, StdioNull, StdioPipe, spawn } from \"child_process\"\n\nexport function spawnAsync(command: string, options?: SpawnOptionsWithoutStdio): Promise<void>\nexport function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe>): Promise<void>\nexport function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioNull>): Promise<void>\nexport function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioPipe>): Promise<void>\nexport function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>): Promise<void>\nexport function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioNull>): Promise<void>\nexport function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioNull>): Promise<void>\nexport function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioPipe>): Promise<void>\nexport function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioNull>): Promise<void>\nexport function spawnAsync(command: string, options: SpawnOptions): Promise<void>\nexport function spawnAsync(command: string, args?: readonly string[], options?: SpawnOptionsWithoutStdio): Promise<void>\nexport function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe>): Promise<void>\nexport function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioNull>): Promise<void>\nexport function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioPipe>): Promise<void>\nexport function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>): Promise<void>\nexport function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioNull>): Promise<void>\nexport function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioNull>): Promise<void>\nexport function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioPipe>): Promise<void>\nexport function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioNull>): Promise<void>\nexport function spawnAsync(command: string, args: readonly string[], options: SpawnOptions): Promise<void>\nexport async function spawnAsync(command: string, args?: any, options?: any) {\n await new Promise<void>((resolve, reject) => {\n const child = spawn(command, args, options)\n child.on(\"exit\", code => {\n if (code !== 0) {\n reject(new Error(`\"${command}\" Command failed with code ${code}`))\n return\n }\n resolve()\n })\n })\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,2BAAgH;AAsBhH,eAAsB,WAAW,SAAiB,MAAY,SAAe;AACzE,QAAM,IAAI,QAAc,CAAC,SAAS,WAAW;AACzC,UAAM,YAAQ,4BAAM,SAAS,MAAM,OAAO;AAC1C,UAAM,GAAG,QAAQ,UAAQ;AACrB,UAAI,SAAS,GAAG;AACZ,eAAO,IAAI,MAAM,IAAI,qCAAqC,MAAM,CAAC;AACjE;AAAA,MACJ;AACA,cAAQ;AAAA,IACZ,CAAC;AAAA,EACL,CAAC;AACL;",
4
+ "sourcesContent": ["import {\n ChildProcess,\n ChildProcessByStdio,\n ChildProcessWithoutNullStreams,\n SpawnOptions,\n SpawnOptionsWithStdioTuple,\n SpawnOptionsWithoutStdio,\n StdioNull,\n StdioPipe,\n spawn,\n} from \"child_process\"\nimport { Readable, Writable } from \"stream\"\n\nexport interface PromiseWithChildProcess<T> extends Promise<T> {\n child: T\n}\n\nexport function spawnAsync(command: string, options?: SpawnOptionsWithoutStdio): PromiseWithChildProcess<ChildProcessWithoutNullStreams>\nexport function spawnAsync(\n command: string,\n options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe>,\n): PromiseWithChildProcess<ChildProcessByStdio<Writable, Readable, Readable>>\nexport function spawnAsync(\n command: string,\n options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioNull>,\n): PromiseWithChildProcess<ChildProcessByStdio<Writable, Readable, null>>\nexport function spawnAsync(\n command: string,\n options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioPipe>,\n): PromiseWithChildProcess<ChildProcessByStdio<Writable, null, Readable>>\nexport function spawnAsync(\n command: string,\n options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>,\n): PromiseWithChildProcess<ChildProcessByStdio<null, Readable, Readable>>\nexport function spawnAsync(\n command: string,\n options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioNull>,\n): PromiseWithChildProcess<ChildProcessByStdio<Writable, null, null>>\nexport function spawnAsync(\n command: string,\n options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioNull>,\n): PromiseWithChildProcess<ChildProcessByStdio<null, Readable, null>>\nexport function spawnAsync(\n command: string,\n options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioPipe>,\n): PromiseWithChildProcess<ChildProcessByStdio<null, null, Readable>>\nexport function spawnAsync(\n command: string,\n options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioNull>,\n): PromiseWithChildProcess<ChildProcessByStdio<null, null, null>>\nexport function spawnAsync(command: string, options: SpawnOptions): PromiseWithChildProcess<ChildProcess>\nexport function spawnAsync(\n command: string,\n args?: readonly string[],\n options?: SpawnOptionsWithoutStdio,\n): PromiseWithChildProcess<ChildProcessWithoutNullStreams>\nexport function spawnAsync(\n command: string,\n args: readonly string[],\n options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe>,\n): PromiseWithChildProcess<ChildProcessByStdio<Writable, Readable, Readable>>\nexport function spawnAsync(\n command: string,\n args: readonly string[],\n options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioNull>,\n): PromiseWithChildProcess<ChildProcessByStdio<Writable, Readable, null>>\nexport function spawnAsync(\n command: string,\n args: readonly string[],\n options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioPipe>,\n): PromiseWithChildProcess<ChildProcessByStdio<Writable, null, Readable>>\nexport function spawnAsync(\n command: string,\n args: readonly string[],\n options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>,\n): PromiseWithChildProcess<ChildProcessByStdio<null, Readable, Readable>>\nexport function spawnAsync(\n command: string,\n args: readonly string[],\n options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioNull>,\n): PromiseWithChildProcess<ChildProcessByStdio<Writable, null, null>>\nexport function spawnAsync(\n command: string,\n args: readonly string[],\n options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioNull>,\n): PromiseWithChildProcess<ChildProcessByStdio<null, Readable, null>>\nexport function spawnAsync(\n command: string,\n args: readonly string[],\n options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioPipe>,\n): PromiseWithChildProcess<ChildProcessByStdio<null, null, Readable>>\nexport function spawnAsync(\n command: string,\n args: readonly string[],\n options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioNull>,\n): PromiseWithChildProcess<ChildProcessByStdio<null, null, null>>\nexport function spawnAsync(command: string, args: readonly string[], options: SpawnOptions): PromiseWithChildProcess<ChildProcess>\n\n/**\n * @description wait for the command to exit\n * @returns a promise that resolves with the child process when the command exits successfully. Also, the child process is attached to the promise as a property.\n */\nexport function spawnAsync(command: string, args?: any, options?: any): Promise<any> {\n const promise = new Promise<any>((resolve, reject) => {\n const child = spawn(command, args, options)\n promise.child = child\n child.on(\"exit\", code => {\n if (code === 0) return resolve(child)\n console.error(`\"${command}\" Command failed with code ${code}`)\n reject(new Error(`\"${command}\" Command failed with code ${code}`))\n return\n })\n }) as PromiseWithChildProcess<any>\n return promise\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,2BAUO;AA4FA,SAAS,WAAW,SAAiB,MAAY,SAA6B;AACjF,QAAM,UAAU,IAAI,QAAa,CAAC,SAAS,WAAW;AAClD,UAAM,YAAQ,4BAAM,SAAS,MAAM,OAAO;AAC1C,YAAQ,QAAQ;AAChB,UAAM,GAAG,QAAQ,UAAQ;AACrB,UAAI,SAAS;AAAG,eAAO,QAAQ,KAAK;AACpC,cAAQ,MAAM,IAAI,qCAAqC,MAAM;AAC7D,aAAO,IAAI,MAAM,IAAI,qCAAqC,MAAM,CAAC;AACjE;AAAA,IACJ,CAAC;AAAA,EACL,CAAC;AACD,SAAO;AACX;",
6
6
  "names": []
7
7
  }
@@ -1,22 +1,27 @@
1
1
  /// <reference types="node" />
2
- import { SpawnOptions, SpawnOptionsWithStdioTuple, SpawnOptionsWithoutStdio, StdioNull, StdioPipe } from "child_process";
3
- export declare function spawnAsync(command: string, options?: SpawnOptionsWithoutStdio): Promise<void>;
4
- export declare function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe>): Promise<void>;
5
- export declare function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioNull>): Promise<void>;
6
- export declare function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioPipe>): Promise<void>;
7
- export declare function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>): Promise<void>;
8
- export declare function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioNull>): Promise<void>;
9
- export declare function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioNull>): Promise<void>;
10
- export declare function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioPipe>): Promise<void>;
11
- export declare function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioNull>): Promise<void>;
12
- export declare function spawnAsync(command: string, options: SpawnOptions): Promise<void>;
13
- export declare function spawnAsync(command: string, args?: readonly string[], options?: SpawnOptionsWithoutStdio): Promise<void>;
14
- export declare function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe>): Promise<void>;
15
- export declare function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioNull>): Promise<void>;
16
- export declare function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioPipe>): Promise<void>;
17
- export declare function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>): Promise<void>;
18
- export declare function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioNull>): Promise<void>;
19
- export declare function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioNull>): Promise<void>;
20
- export declare function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioPipe>): Promise<void>;
21
- export declare function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioNull>): Promise<void>;
22
- export declare function spawnAsync(command: string, args: readonly string[], options: SpawnOptions): Promise<void>;
2
+ /// <reference types="node" />
3
+ import { ChildProcess, ChildProcessByStdio, ChildProcessWithoutNullStreams, SpawnOptions, SpawnOptionsWithStdioTuple, SpawnOptionsWithoutStdio, StdioNull, StdioPipe } from "child_process";
4
+ import { Readable, Writable } from "stream";
5
+ export interface PromiseWithChildProcess<T> extends Promise<T> {
6
+ child: T;
7
+ }
8
+ export declare function spawnAsync(command: string, options?: SpawnOptionsWithoutStdio): PromiseWithChildProcess<ChildProcessWithoutNullStreams>;
9
+ export declare function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe>): PromiseWithChildProcess<ChildProcessByStdio<Writable, Readable, Readable>>;
10
+ export declare function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioNull>): PromiseWithChildProcess<ChildProcessByStdio<Writable, Readable, null>>;
11
+ export declare function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioPipe>): PromiseWithChildProcess<ChildProcessByStdio<Writable, null, Readable>>;
12
+ export declare function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>): PromiseWithChildProcess<ChildProcessByStdio<null, Readable, Readable>>;
13
+ export declare function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioNull>): PromiseWithChildProcess<ChildProcessByStdio<Writable, null, null>>;
14
+ export declare function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioNull>): PromiseWithChildProcess<ChildProcessByStdio<null, Readable, null>>;
15
+ export declare function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioPipe>): PromiseWithChildProcess<ChildProcessByStdio<null, null, Readable>>;
16
+ export declare function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioNull>): PromiseWithChildProcess<ChildProcessByStdio<null, null, null>>;
17
+ export declare function spawnAsync(command: string, options: SpawnOptions): PromiseWithChildProcess<ChildProcess>;
18
+ export declare function spawnAsync(command: string, args?: readonly string[], options?: SpawnOptionsWithoutStdio): PromiseWithChildProcess<ChildProcessWithoutNullStreams>;
19
+ export declare function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe>): PromiseWithChildProcess<ChildProcessByStdio<Writable, Readable, Readable>>;
20
+ export declare function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioNull>): PromiseWithChildProcess<ChildProcessByStdio<Writable, Readable, null>>;
21
+ export declare function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioPipe>): PromiseWithChildProcess<ChildProcessByStdio<Writable, null, Readable>>;
22
+ export declare function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>): PromiseWithChildProcess<ChildProcessByStdio<null, Readable, Readable>>;
23
+ export declare function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioNull>): PromiseWithChildProcess<ChildProcessByStdio<Writable, null, null>>;
24
+ export declare function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioNull>): PromiseWithChildProcess<ChildProcessByStdio<null, Readable, null>>;
25
+ export declare function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioPipe>): PromiseWithChildProcess<ChildProcessByStdio<null, null, Readable>>;
26
+ export declare function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioNull>): PromiseWithChildProcess<ChildProcessByStdio<null, null, null>>;
27
+ export declare function spawnAsync(command: string, args: readonly string[], options: SpawnOptions): PromiseWithChildProcess<ChildProcess>;
@@ -1,14 +1,19 @@
1
1
  import { spawn } from "child_process";
2
- export async function spawnAsync(command, args, options) {
3
- await new Promise((resolve, reject) => {
2
+ /**
3
+ * @description wait for the command to exit
4
+ * @returns a promise that resolves with the child process when the command exits successfully. Also, the child process is attached to the promise as a property.
5
+ */
6
+ export function spawnAsync(command, args, options) {
7
+ const promise = new Promise((resolve, reject) => {
4
8
  const child = spawn(command, args, options);
9
+ promise.child = child;
5
10
  child.on("exit", code => {
6
- if (code !== 0) {
7
- reject(new Error(`"${command}" Command failed with code ${code}`));
8
- return;
9
- }
10
- resolve();
11
+ if (code === 0) return resolve(child);
12
+ console.error(`"${command}" Command failed with code ${code}`);
13
+ reject(new Error(`"${command}" Command failed with code ${code}`));
14
+ return;
11
15
  });
12
16
  });
17
+ return promise;
13
18
  }
14
19
  //# sourceMappingURL=spawnAsync.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["spawn","spawnAsync","command","args","options","Promise","resolve","reject","child","on","code","Error"],"sources":["../../../src/utils/spawnAsync.ts"],"sourcesContent":["import { SpawnOptions, SpawnOptionsWithStdioTuple, SpawnOptionsWithoutStdio, StdioNull, StdioPipe, spawn } from \"child_process\"\n\nexport function spawnAsync(command: string, options?: SpawnOptionsWithoutStdio): Promise<void>\nexport function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe>): Promise<void>\nexport function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioNull>): Promise<void>\nexport function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioPipe>): Promise<void>\nexport function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>): Promise<void>\nexport function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioNull>): Promise<void>\nexport function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioNull>): Promise<void>\nexport function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioPipe>): Promise<void>\nexport function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioNull>): Promise<void>\nexport function spawnAsync(command: string, options: SpawnOptions): Promise<void>\nexport function spawnAsync(command: string, args?: readonly string[], options?: SpawnOptionsWithoutStdio): Promise<void>\nexport function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe>): Promise<void>\nexport function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioNull>): Promise<void>\nexport function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioPipe>): Promise<void>\nexport function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>): Promise<void>\nexport function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioNull>): Promise<void>\nexport function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioNull>): Promise<void>\nexport function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioPipe>): Promise<void>\nexport function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioNull>): Promise<void>\nexport function spawnAsync(command: string, args: readonly string[], options: SpawnOptions): Promise<void>\nexport async function spawnAsync(command: string, args?: any, options?: any) {\n await new Promise<void>((resolve, reject) => {\n const child = spawn(command, args, options)\n child.on(\"exit\", code => {\n if (code !== 0) {\n reject(new Error(`\"${command}\" Command failed with code ${code}`))\n return\n }\n resolve()\n })\n })\n}\n"],"mappings":"AAAA,SAAmGA,KAAK,QAAQ,eAAe;AAsB/H,OAAO,eAAeC,UAAUA,CAACC,OAAe,EAAEC,IAAU,EAAEC,OAAa,EAAE;EACzE,MAAM,IAAIC,OAAO,CAAO,CAACC,OAAO,EAAEC,MAAM,KAAK;IACzC,MAAMC,KAAK,GAAGR,KAAK,CAACE,OAAO,EAAEC,IAAI,EAAEC,OAAO,CAAC;IAC3CI,KAAK,CAACC,EAAE,CAAC,MAAM,EAAEC,IAAI,IAAI;MACrB,IAAIA,IAAI,KAAK,CAAC,EAAE;QACZH,MAAM,CAAC,IAAII,KAAK,CAAE,IAAGT,OAAQ,8BAA6BQ,IAAK,EAAC,CAAC,CAAC;QAClE;MACJ;MACAJ,OAAO,CAAC,CAAC;IACb,CAAC,CAAC;EACN,CAAC,CAAC;AACN"}
1
+ {"version":3,"names":["spawn","spawnAsync","command","args","options","promise","Promise","resolve","reject","child","on","code","console","error","Error"],"sources":["../../../src/utils/spawnAsync.ts"],"sourcesContent":["import {\n ChildProcess,\n ChildProcessByStdio,\n ChildProcessWithoutNullStreams,\n SpawnOptions,\n SpawnOptionsWithStdioTuple,\n SpawnOptionsWithoutStdio,\n StdioNull,\n StdioPipe,\n spawn,\n} from \"child_process\"\nimport { Readable, Writable } from \"stream\"\n\nexport interface PromiseWithChildProcess<T> extends Promise<T> {\n child: T\n}\n\nexport function spawnAsync(command: string, options?: SpawnOptionsWithoutStdio): PromiseWithChildProcess<ChildProcessWithoutNullStreams>\nexport function spawnAsync(\n command: string,\n options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe>,\n): PromiseWithChildProcess<ChildProcessByStdio<Writable, Readable, Readable>>\nexport function spawnAsync(\n command: string,\n options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioNull>,\n): PromiseWithChildProcess<ChildProcessByStdio<Writable, Readable, null>>\nexport function spawnAsync(\n command: string,\n options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioPipe>,\n): PromiseWithChildProcess<ChildProcessByStdio<Writable, null, Readable>>\nexport function spawnAsync(\n command: string,\n options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>,\n): PromiseWithChildProcess<ChildProcessByStdio<null, Readable, Readable>>\nexport function spawnAsync(\n command: string,\n options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioNull>,\n): PromiseWithChildProcess<ChildProcessByStdio<Writable, null, null>>\nexport function spawnAsync(\n command: string,\n options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioNull>,\n): PromiseWithChildProcess<ChildProcessByStdio<null, Readable, null>>\nexport function spawnAsync(\n command: string,\n options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioPipe>,\n): PromiseWithChildProcess<ChildProcessByStdio<null, null, Readable>>\nexport function spawnAsync(\n command: string,\n options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioNull>,\n): PromiseWithChildProcess<ChildProcessByStdio<null, null, null>>\nexport function spawnAsync(command: string, options: SpawnOptions): PromiseWithChildProcess<ChildProcess>\nexport function spawnAsync(\n command: string,\n args?: readonly string[],\n options?: SpawnOptionsWithoutStdio,\n): PromiseWithChildProcess<ChildProcessWithoutNullStreams>\nexport function spawnAsync(\n command: string,\n args: readonly string[],\n options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe>,\n): PromiseWithChildProcess<ChildProcessByStdio<Writable, Readable, Readable>>\nexport function spawnAsync(\n command: string,\n args: readonly string[],\n options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioNull>,\n): PromiseWithChildProcess<ChildProcessByStdio<Writable, Readable, null>>\nexport function spawnAsync(\n command: string,\n args: readonly string[],\n options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioPipe>,\n): PromiseWithChildProcess<ChildProcessByStdio<Writable, null, Readable>>\nexport function spawnAsync(\n command: string,\n args: readonly string[],\n options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>,\n): PromiseWithChildProcess<ChildProcessByStdio<null, Readable, Readable>>\nexport function spawnAsync(\n command: string,\n args: readonly string[],\n options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioNull>,\n): PromiseWithChildProcess<ChildProcessByStdio<Writable, null, null>>\nexport function spawnAsync(\n command: string,\n args: readonly string[],\n options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioNull>,\n): PromiseWithChildProcess<ChildProcessByStdio<null, Readable, null>>\nexport function spawnAsync(\n command: string,\n args: readonly string[],\n options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioPipe>,\n): PromiseWithChildProcess<ChildProcessByStdio<null, null, Readable>>\nexport function spawnAsync(\n command: string,\n args: readonly string[],\n options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioNull>,\n): PromiseWithChildProcess<ChildProcessByStdio<null, null, null>>\nexport function spawnAsync(command: string, args: readonly string[], options: SpawnOptions): PromiseWithChildProcess<ChildProcess>\n\n/**\n * @description wait for the command to exit\n * @returns a promise that resolves with the child process when the command exits successfully. Also, the child process is attached to the promise as a property.\n */\nexport function spawnAsync(command: string, args?: any, options?: any): Promise<any> {\n const promise = new Promise<any>((resolve, reject) => {\n const child = spawn(command, args, options)\n promise.child = child\n child.on(\"exit\", code => {\n if (code === 0) return resolve(child)\n console.error(`\"${command}\" Command failed with code ${code}`)\n reject(new Error(`\"${command}\" Command failed with code ${code}`))\n return\n })\n }) as PromiseWithChildProcess<any>\n return promise\n}\n"],"mappings":"AAAA,SASIA,KAAK,QACF,eAAe;AAwFtB;AACA;AACA;AACA;AACA,OAAO,SAASC,UAAUA,CAACC,OAAe,EAAEC,IAAU,EAAEC,OAAa,EAAgB;EACjF,MAAMC,OAAO,GAAG,IAAIC,OAAO,CAAM,CAACC,OAAO,EAAEC,MAAM,KAAK;IAClD,MAAMC,KAAK,GAAGT,KAAK,CAACE,OAAO,EAAEC,IAAI,EAAEC,OAAO,CAAC;IAC3CC,OAAO,CAACI,KAAK,GAAGA,KAAK;IACrBA,KAAK,CAACC,EAAE,CAAC,MAAM,EAAEC,IAAI,IAAI;MACrB,IAAIA,IAAI,KAAK,CAAC,EAAE,OAAOJ,OAAO,CAACE,KAAK,CAAC;MACrCG,OAAO,CAACC,KAAK,CAAE,IAAGX,OAAQ,8BAA6BS,IAAK,EAAC,CAAC;MAC9DH,MAAM,CAAC,IAAIM,KAAK,CAAE,IAAGZ,OAAQ,8BAA6BS,IAAK,EAAC,CAAC,CAAC;MAClE;IACJ,CAAC,CAAC;EACN,CAAC,CAAiC;EAClC,OAAON,OAAO;AAClB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "soda-nodejs",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
4
4
  "description": "",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -1,34 +1,115 @@
1
- import { SpawnOptions, SpawnOptionsWithStdioTuple, SpawnOptionsWithoutStdio, StdioNull, StdioPipe, spawn } from "child_process"
1
+ import {
2
+ ChildProcess,
3
+ ChildProcessByStdio,
4
+ ChildProcessWithoutNullStreams,
5
+ SpawnOptions,
6
+ SpawnOptionsWithStdioTuple,
7
+ SpawnOptionsWithoutStdio,
8
+ StdioNull,
9
+ StdioPipe,
10
+ spawn,
11
+ } from "child_process"
12
+ import { Readable, Writable } from "stream"
2
13
 
3
- export function spawnAsync(command: string, options?: SpawnOptionsWithoutStdio): Promise<void>
4
- export function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe>): Promise<void>
5
- export function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioNull>): Promise<void>
6
- export function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioPipe>): Promise<void>
7
- export function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>): Promise<void>
8
- export function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioNull>): Promise<void>
9
- export function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioNull>): Promise<void>
10
- export function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioPipe>): Promise<void>
11
- export function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioNull>): Promise<void>
12
- export function spawnAsync(command: string, options: SpawnOptions): Promise<void>
13
- export function spawnAsync(command: string, args?: readonly string[], options?: SpawnOptionsWithoutStdio): Promise<void>
14
- export function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe>): Promise<void>
15
- export function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioNull>): Promise<void>
16
- export function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioPipe>): Promise<void>
17
- export function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>): Promise<void>
18
- export function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioNull>): Promise<void>
19
- export function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioNull>): Promise<void>
20
- export function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioPipe>): Promise<void>
21
- export function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioNull>): Promise<void>
22
- export function spawnAsync(command: string, args: readonly string[], options: SpawnOptions): Promise<void>
23
- export async function spawnAsync(command: string, args?: any, options?: any) {
24
- await new Promise<void>((resolve, reject) => {
14
+ export interface PromiseWithChildProcess<T> extends Promise<T> {
15
+ child: T
16
+ }
17
+
18
+ export function spawnAsync(command: string, options?: SpawnOptionsWithoutStdio): PromiseWithChildProcess<ChildProcessWithoutNullStreams>
19
+ export function spawnAsync(
20
+ command: string,
21
+ options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe>,
22
+ ): PromiseWithChildProcess<ChildProcessByStdio<Writable, Readable, Readable>>
23
+ export function spawnAsync(
24
+ command: string,
25
+ options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioNull>,
26
+ ): PromiseWithChildProcess<ChildProcessByStdio<Writable, Readable, null>>
27
+ export function spawnAsync(
28
+ command: string,
29
+ options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioPipe>,
30
+ ): PromiseWithChildProcess<ChildProcessByStdio<Writable, null, Readable>>
31
+ export function spawnAsync(
32
+ command: string,
33
+ options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>,
34
+ ): PromiseWithChildProcess<ChildProcessByStdio<null, Readable, Readable>>
35
+ export function spawnAsync(
36
+ command: string,
37
+ options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioNull>,
38
+ ): PromiseWithChildProcess<ChildProcessByStdio<Writable, null, null>>
39
+ export function spawnAsync(
40
+ command: string,
41
+ options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioNull>,
42
+ ): PromiseWithChildProcess<ChildProcessByStdio<null, Readable, null>>
43
+ export function spawnAsync(
44
+ command: string,
45
+ options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioPipe>,
46
+ ): PromiseWithChildProcess<ChildProcessByStdio<null, null, Readable>>
47
+ export function spawnAsync(
48
+ command: string,
49
+ options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioNull>,
50
+ ): PromiseWithChildProcess<ChildProcessByStdio<null, null, null>>
51
+ export function spawnAsync(command: string, options: SpawnOptions): PromiseWithChildProcess<ChildProcess>
52
+ export function spawnAsync(
53
+ command: string,
54
+ args?: readonly string[],
55
+ options?: SpawnOptionsWithoutStdio,
56
+ ): PromiseWithChildProcess<ChildProcessWithoutNullStreams>
57
+ export function spawnAsync(
58
+ command: string,
59
+ args: readonly string[],
60
+ options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe>,
61
+ ): PromiseWithChildProcess<ChildProcessByStdio<Writable, Readable, Readable>>
62
+ export function spawnAsync(
63
+ command: string,
64
+ args: readonly string[],
65
+ options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioNull>,
66
+ ): PromiseWithChildProcess<ChildProcessByStdio<Writable, Readable, null>>
67
+ export function spawnAsync(
68
+ command: string,
69
+ args: readonly string[],
70
+ options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioPipe>,
71
+ ): PromiseWithChildProcess<ChildProcessByStdio<Writable, null, Readable>>
72
+ export function spawnAsync(
73
+ command: string,
74
+ args: readonly string[],
75
+ options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>,
76
+ ): PromiseWithChildProcess<ChildProcessByStdio<null, Readable, Readable>>
77
+ export function spawnAsync(
78
+ command: string,
79
+ args: readonly string[],
80
+ options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioNull>,
81
+ ): PromiseWithChildProcess<ChildProcessByStdio<Writable, null, null>>
82
+ export function spawnAsync(
83
+ command: string,
84
+ args: readonly string[],
85
+ options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioNull>,
86
+ ): PromiseWithChildProcess<ChildProcessByStdio<null, Readable, null>>
87
+ export function spawnAsync(
88
+ command: string,
89
+ args: readonly string[],
90
+ options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioPipe>,
91
+ ): PromiseWithChildProcess<ChildProcessByStdio<null, null, Readable>>
92
+ export function spawnAsync(
93
+ command: string,
94
+ args: readonly string[],
95
+ options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioNull>,
96
+ ): PromiseWithChildProcess<ChildProcessByStdio<null, null, null>>
97
+ export function spawnAsync(command: string, args: readonly string[], options: SpawnOptions): PromiseWithChildProcess<ChildProcess>
98
+
99
+ /**
100
+ * @description wait for the command to exit
101
+ * @returns a promise that resolves with the child process when the command exits successfully. Also, the child process is attached to the promise as a property.
102
+ */
103
+ export function spawnAsync(command: string, args?: any, options?: any): Promise<any> {
104
+ const promise = new Promise<any>((resolve, reject) => {
25
105
  const child = spawn(command, args, options)
106
+ promise.child = child
26
107
  child.on("exit", code => {
27
- if (code !== 0) {
28
- reject(new Error(`"${command}" Command failed with code ${code}`))
29
- return
30
- }
31
- resolve()
108
+ if (code === 0) return resolve(child)
109
+ console.error(`"${command}" Command failed with code ${code}`)
110
+ reject(new Error(`"${command}" Command failed with code ${code}`))
111
+ return
32
112
  })
33
- })
113
+ }) as PromiseWithChildProcess<any>
114
+ return promise
34
115
  }