soda-nodejs 0.5.1 → 0.5.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.
@@ -48,8 +48,14 @@ function spawnAsync(command, args, options) {
48
48
  child.on("exit", (code) => {
49
49
  if (code === 0)
50
50
  return resolve(child);
51
- console.error(`"${command}" Command failed with code ${code}`);
52
- reject(new Error(`"${command}" Command failed with code ${code}`));
51
+ let command2 = command;
52
+ if (Array.isArray(args)) {
53
+ const args2 = args.map((item) => item.trim()).filter(Boolean);
54
+ if (args2.length > 0)
55
+ command2 = `${command2} ${args2.join(" ")}`;
56
+ }
57
+ console.error(`"${command2}" Command failed with code ${code}`);
58
+ reject(new Error(`"${command2}" Command failed with code ${code}`));
53
59
  return;
54
60
  });
55
61
  });
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/utils/spawnAsync.ts"],
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 type Options =\n | SpawnOptionsWithoutStdio\n | SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe>\n | SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioNull>\n | SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioPipe>\n | SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>\n | SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioNull>\n | SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioNull>\n | SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioPipe>\n | SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioNull>\n | SpawnOptions\n\nlet defaultOptions: Options = {}\n\n/**\n * @description get default options for spawnAsync\n * @returns {Options} options\n */\nexport function getDefaultOptions(): Options {\n return defaultOptions\n}\n\n/**\n * @description set default options for spawnAsync\n * @param {Options | ((prev: Options) => Options)} options\n */\nexport function setDefaultOptions(options: Options | ((prev: Options) => Options)) {\n if (typeof options === \"function\") {\n defaultOptions = options(defaultOptions)\n return\n }\n defaultOptions = options\n return defaultOptions\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 let child: any\n const promise = new Promise<any>((resolve, reject) => {\n if (Array.isArray(args)) options = { ...defaultOptions, ...options }\n else args = { ...defaultOptions, ...args }\n child = spawn(command, args, options)\n child.on(\"exit\", (code: number) => {\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 promise.child = child\n return promise\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,2BAUO;AAmBP,IAAI,iBAA0B,CAAC;AAMxB,SAAS,oBAA6B;AACzC,SAAO;AACX;AAMO,SAAS,kBAAkB,SAAiD;AAC/E,MAAI,OAAO,YAAY,YAAY;AAC/B,qBAAiB,QAAQ,cAAc;AACvC;AAAA,EACJ;AACA,mBAAiB;AACjB,SAAO;AACX;AAuFO,SAAS,WAAW,SAAiB,MAAY,SAA6B;AACjF,MAAI;AACJ,QAAM,UAAU,IAAI,QAAa,CAAC,SAAS,WAAW;AAClD,QAAI,MAAM,QAAQ,IAAI;AAAG,gBAAU,EAAE,GAAG,gBAAgB,GAAG,QAAQ;AAAA;AAC9D,aAAO,EAAE,GAAG,gBAAgB,GAAG,KAAK;AACzC,gBAAQ,4BAAM,SAAS,MAAM,OAAO;AACpC,UAAM,GAAG,QAAQ,CAAC,SAAiB;AAC/B,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,UAAQ,QAAQ;AAChB,SAAO;AACX;",
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 type Options =\n | SpawnOptionsWithoutStdio\n | SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe>\n | SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioNull>\n | SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioPipe>\n | SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>\n | SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioNull>\n | SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioNull>\n | SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioPipe>\n | SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioNull>\n | SpawnOptions\n\nlet defaultOptions: Options = {}\n\n/**\n * @description get default options for spawnAsync\n * @returns {Options} options\n */\nexport function getDefaultOptions(): Options {\n return defaultOptions\n}\n\n/**\n * @description set default options for spawnAsync\n * @param {Options | ((prev: Options) => Options)} options\n */\nexport function setDefaultOptions(options: Options | ((prev: Options) => Options)) {\n if (typeof options === \"function\") {\n defaultOptions = options(defaultOptions)\n return\n }\n defaultOptions = options\n return defaultOptions\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 let child: any\n const promise = new Promise<any>((resolve, reject) => {\n if (Array.isArray(args)) options = { ...defaultOptions, ...options }\n else args = { ...defaultOptions, ...args }\n child = spawn(command, args, options)\n child.on(\"exit\", (code: number) => {\n if (code === 0) return resolve(child)\n let command2 = command\n if (Array.isArray(args)) {\n const args2 = args.map((item: string) => item.trim()).filter(Boolean)\n if (args2.length > 0) command2 = `${command2} ${args2.join(\" \")}`\n }\n console.error(`\"${command2}\" Command failed with code ${code}`)\n reject(new Error(`\"${command2}\" Command failed with code ${code}`))\n return\n })\n }) as PromiseWithChildProcess<any>\n promise.child = child\n return promise\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,2BAUO;AAmBP,IAAI,iBAA0B,CAAC;AAMxB,SAAS,oBAA6B;AACzC,SAAO;AACX;AAMO,SAAS,kBAAkB,SAAiD;AAC/E,MAAI,OAAO,YAAY,YAAY;AAC/B,qBAAiB,QAAQ,cAAc;AACvC;AAAA,EACJ;AACA,mBAAiB;AACjB,SAAO;AACX;AAuFO,SAAS,WAAW,SAAiB,MAAY,SAA6B;AACjF,MAAI;AACJ,QAAM,UAAU,IAAI,QAAa,CAAC,SAAS,WAAW;AAClD,QAAI,MAAM,QAAQ,IAAI;AAAG,gBAAU,EAAE,GAAG,gBAAgB,GAAG,QAAQ;AAAA;AAC9D,aAAO,EAAE,GAAG,gBAAgB,GAAG,KAAK;AACzC,gBAAQ,4BAAM,SAAS,MAAM,OAAO;AACpC,UAAM,GAAG,QAAQ,CAAC,SAAiB;AAC/B,UAAI,SAAS;AAAG,eAAO,QAAQ,KAAK;AACpC,UAAI,WAAW;AACf,UAAI,MAAM,QAAQ,IAAI,GAAG;AACrB,cAAM,QAAQ,KAAK,IAAI,CAAC,SAAiB,KAAK,KAAK,CAAC,EAAE,OAAO,OAAO;AACpE,YAAI,MAAM,SAAS;AAAG,qBAAW,GAAG,YAAY,MAAM,KAAK,GAAG;AAAA,MAClE;AACA,cAAQ,MAAM,IAAI,sCAAsC,MAAM;AAC9D,aAAO,IAAI,MAAM,IAAI,sCAAsC,MAAM,CAAC;AAClE;AAAA,IACJ,CAAC;AAAA,EACL,CAAC;AACD,UAAQ,QAAQ;AAChB,SAAO;AACX;",
6
6
  "names": []
7
7
  }
@@ -38,8 +38,13 @@ export function spawnAsync(command, args, options) {
38
38
  child = spawn(command, args, options);
39
39
  child.on("exit", code => {
40
40
  if (code === 0) return resolve(child);
41
- console.error(`"${command}" Command failed with code ${code}`);
42
- reject(new Error(`"${command}" Command failed with code ${code}`));
41
+ let command2 = command;
42
+ if (Array.isArray(args)) {
43
+ const args2 = args.map(item => item.trim()).filter(Boolean);
44
+ if (args2.length > 0) command2 = `${command2} ${args2.join(" ")}`;
45
+ }
46
+ console.error(`"${command2}" Command failed with code ${code}`);
47
+ reject(new Error(`"${command2}" Command failed with code ${code}`));
43
48
  return;
44
49
  });
45
50
  });
@@ -1 +1 @@
1
- {"version":3,"names":["spawn","defaultOptions","getDefaultOptions","setDefaultOptions","options","spawnAsync","command","args","child","promise","Promise","resolve","reject","Array","isArray","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 type Options =\n | SpawnOptionsWithoutStdio\n | SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe>\n | SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioNull>\n | SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioPipe>\n | SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>\n | SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioNull>\n | SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioNull>\n | SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioPipe>\n | SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioNull>\n | SpawnOptions\n\nlet defaultOptions: Options = {}\n\n/**\n * @description get default options for spawnAsync\n * @returns {Options} options\n */\nexport function getDefaultOptions(): Options {\n return defaultOptions\n}\n\n/**\n * @description set default options for spawnAsync\n * @param {Options | ((prev: Options) => Options)} options\n */\nexport function setDefaultOptions(options: Options | ((prev: Options) => Options)) {\n if (typeof options === \"function\") {\n defaultOptions = options(defaultOptions)\n return\n }\n defaultOptions = options\n return defaultOptions\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 let child: any\n const promise = new Promise<any>((resolve, reject) => {\n if (Array.isArray(args)) options = { ...defaultOptions, ...options }\n else args = { ...defaultOptions, ...args }\n child = spawn(command, args, options)\n child.on(\"exit\", (code: number) => {\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 promise.child = child\n return promise\n}\n"],"mappings":"AAAA,SASIA,KAAK,QACF,eAAe;AAmBtB,IAAIC,cAAuB,GAAG,CAAC,CAAC;;AAEhC;AACA;AACA;AACA;AACA,OAAO,SAASC,iBAAiBA,CAAA,EAAY;EACzC,OAAOD,cAAc;AACzB;;AAEA;AACA;AACA;AACA;AACA,OAAO,SAASE,iBAAiBA,CAACC,OAA+C,EAAE;EAC/E,IAAI,OAAOA,OAAO,KAAK,UAAU,EAAE;IAC/BH,cAAc,GAAGG,OAAO,CAACH,cAAc,CAAC;IACxC;EACJ;EACAA,cAAc,GAAGG,OAAO;EACxB,OAAOH,cAAc;AACzB;AAmFA;AACA;AACA;AACA;AACA,OAAO,SAASI,UAAUA,CAACC,OAAe,EAAEC,IAAU,EAAEH,OAAa,EAAgB;EACjF,IAAII,KAAU;EACd,MAAMC,OAAO,GAAG,IAAIC,OAAO,CAAM,CAACC,OAAO,EAAEC,MAAM,KAAK;IAClD,IAAIC,KAAK,CAACC,OAAO,CAACP,IAAI,CAAC,EAAEH,OAAO,GAAG;MAAE,GAAGH,cAAc;MAAE,GAAGG;IAAQ,CAAC,MAC/DG,IAAI,GAAG;MAAE,GAAGN,cAAc;MAAE,GAAGM;IAAK,CAAC;IAC1CC,KAAK,GAAGR,KAAK,CAACM,OAAO,EAAEC,IAAI,EAAEH,OAAO,CAAC;IACrCI,KAAK,CAACO,EAAE,CAAC,MAAM,EAAGC,IAAY,IAAK;MAC/B,IAAIA,IAAI,KAAK,CAAC,EAAE,OAAOL,OAAO,CAACH,KAAK,CAAC;MACrCS,OAAO,CAACC,KAAK,CAAE,IAAGZ,OAAQ,8BAA6BU,IAAK,EAAC,CAAC;MAC9DJ,MAAM,CAAC,IAAIO,KAAK,CAAE,IAAGb,OAAQ,8BAA6BU,IAAK,EAAC,CAAC,CAAC;MAClE;IACJ,CAAC,CAAC;EACN,CAAC,CAAiC;EAClCP,OAAO,CAACD,KAAK,GAAGA,KAAK;EACrB,OAAOC,OAAO;AAClB"}
1
+ {"version":3,"names":["spawn","defaultOptions","getDefaultOptions","setDefaultOptions","options","spawnAsync","command","args","child","promise","Promise","resolve","reject","Array","isArray","on","code","command2","args2","map","item","trim","filter","Boolean","length","join","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 type Options =\n | SpawnOptionsWithoutStdio\n | SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe>\n | SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioNull>\n | SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioPipe>\n | SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>\n | SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioNull>\n | SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioNull>\n | SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioPipe>\n | SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioNull>\n | SpawnOptions\n\nlet defaultOptions: Options = {}\n\n/**\n * @description get default options for spawnAsync\n * @returns {Options} options\n */\nexport function getDefaultOptions(): Options {\n return defaultOptions\n}\n\n/**\n * @description set default options for spawnAsync\n * @param {Options | ((prev: Options) => Options)} options\n */\nexport function setDefaultOptions(options: Options | ((prev: Options) => Options)) {\n if (typeof options === \"function\") {\n defaultOptions = options(defaultOptions)\n return\n }\n defaultOptions = options\n return defaultOptions\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 let child: any\n const promise = new Promise<any>((resolve, reject) => {\n if (Array.isArray(args)) options = { ...defaultOptions, ...options }\n else args = { ...defaultOptions, ...args }\n child = spawn(command, args, options)\n child.on(\"exit\", (code: number) => {\n if (code === 0) return resolve(child)\n let command2 = command\n if (Array.isArray(args)) {\n const args2 = args.map((item: string) => item.trim()).filter(Boolean)\n if (args2.length > 0) command2 = `${command2} ${args2.join(\" \")}`\n }\n console.error(`\"${command2}\" Command failed with code ${code}`)\n reject(new Error(`\"${command2}\" Command failed with code ${code}`))\n return\n })\n }) as PromiseWithChildProcess<any>\n promise.child = child\n return promise\n}\n"],"mappings":"AAAA,SASIA,KAAK,QACF,eAAe;AAmBtB,IAAIC,cAAuB,GAAG,CAAC,CAAC;;AAEhC;AACA;AACA;AACA;AACA,OAAO,SAASC,iBAAiBA,CAAA,EAAY;EACzC,OAAOD,cAAc;AACzB;;AAEA;AACA;AACA;AACA;AACA,OAAO,SAASE,iBAAiBA,CAACC,OAA+C,EAAE;EAC/E,IAAI,OAAOA,OAAO,KAAK,UAAU,EAAE;IAC/BH,cAAc,GAAGG,OAAO,CAACH,cAAc,CAAC;IACxC;EACJ;EACAA,cAAc,GAAGG,OAAO;EACxB,OAAOH,cAAc;AACzB;AAmFA;AACA;AACA;AACA;AACA,OAAO,SAASI,UAAUA,CAACC,OAAe,EAAEC,IAAU,EAAEH,OAAa,EAAgB;EACjF,IAAII,KAAU;EACd,MAAMC,OAAO,GAAG,IAAIC,OAAO,CAAM,CAACC,OAAO,EAAEC,MAAM,KAAK;IAClD,IAAIC,KAAK,CAACC,OAAO,CAACP,IAAI,CAAC,EAAEH,OAAO,GAAG;MAAE,GAAGH,cAAc;MAAE,GAAGG;IAAQ,CAAC,MAC/DG,IAAI,GAAG;MAAE,GAAGN,cAAc;MAAE,GAAGM;IAAK,CAAC;IAC1CC,KAAK,GAAGR,KAAK,CAACM,OAAO,EAAEC,IAAI,EAAEH,OAAO,CAAC;IACrCI,KAAK,CAACO,EAAE,CAAC,MAAM,EAAGC,IAAY,IAAK;MAC/B,IAAIA,IAAI,KAAK,CAAC,EAAE,OAAOL,OAAO,CAACH,KAAK,CAAC;MACrC,IAAIS,QAAQ,GAAGX,OAAO;MACtB,IAAIO,KAAK,CAACC,OAAO,CAACP,IAAI,CAAC,EAAE;QACrB,MAAMW,KAAK,GAAGX,IAAI,CAACY,GAAG,CAAEC,IAAY,IAAKA,IAAI,CAACC,IAAI,CAAC,CAAC,CAAC,CAACC,MAAM,CAACC,OAAO,CAAC;QACrE,IAAIL,KAAK,CAACM,MAAM,GAAG,CAAC,EAAEP,QAAQ,GAAI,GAAEA,QAAS,IAAGC,KAAK,CAACO,IAAI,CAAC,GAAG,CAAE,EAAC;MACrE;MACAC,OAAO,CAACC,KAAK,CAAE,IAAGV,QAAS,8BAA6BD,IAAK,EAAC,CAAC;MAC/DJ,MAAM,CAAC,IAAIgB,KAAK,CAAE,IAAGX,QAAS,8BAA6BD,IAAK,EAAC,CAAC,CAAC;MACnE;IACJ,CAAC,CAAC;EACN,CAAC,CAAiC;EAClCP,OAAO,CAACD,KAAK,GAAGA,KAAK;EACrB,OAAOC,OAAO;AAClB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "soda-nodejs",
3
- "version": "0.5.1",
3
+ "version": "0.5.3",
4
4
  "description": "",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -23,7 +23,7 @@
23
23
  },
24
24
  "homepage": "https://github.com/1adybug/deepsea/tree/main/packages/soda-nodejs",
25
25
  "devDependencies": {
26
- "@types/node": "^20.17.6",
26
+ "@types/node": "^20.17.10",
27
27
  "@types/which": "^3.0.4"
28
28
  },
29
29
  "dependencies": {
@@ -143,8 +143,13 @@ export function spawnAsync(command: string, args?: any, options?: any): Promise<
143
143
  child = spawn(command, args, options)
144
144
  child.on("exit", (code: number) => {
145
145
  if (code === 0) return resolve(child)
146
- console.error(`"${command}" Command failed with code ${code}`)
147
- reject(new Error(`"${command}" Command failed with code ${code}`))
146
+ let command2 = command
147
+ if (Array.isArray(args)) {
148
+ const args2 = args.map((item: string) => item.trim()).filter(Boolean)
149
+ if (args2.length > 0) command2 = `${command2} ${args2.join(" ")}`
150
+ }
151
+ console.error(`"${command2}" Command failed with code ${code}`)
152
+ reject(new Error(`"${command2}" Command failed with code ${code}`))
148
153
  return
149
154
  })
150
155
  }) as PromiseWithChildProcess<any>