@willbooster/shared-lib-node 2.2.2 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/exists.cjs.map +1 -0
- package/dist/cjs/spawn.cjs +2 -0
- package/dist/cjs/spawn.cjs.map +1 -0
- package/dist/esm/exists.js.map +1 -0
- package/dist/esm/spawn.js +2 -0
- package/dist/esm/spawn.js.map +1 -0
- package/package.json +14 -11
- package/dist/cjs/_virtual/_commonjsHelpers.cjs +0 -2
- package/dist/cjs/_virtual/_commonjsHelpers.cjs.map +0 -1
- package/dist/cjs/node_modules/tree-kill/index.cjs +0 -2
- package/dist/cjs/node_modules/tree-kill/index.cjs.map +0 -1
- package/dist/cjs/packages/shared-lib-node/src/exists.cjs.map +0 -1
- package/dist/cjs/packages/shared-lib-node/src/spawn.cjs +0 -2
- package/dist/cjs/packages/shared-lib-node/src/spawn.cjs.map +0 -1
- package/dist/esm/_virtual/_commonjsHelpers.js +0 -2
- package/dist/esm/_virtual/_commonjsHelpers.js.map +0 -1
- package/dist/esm/node_modules/tree-kill/index.js +0 -2
- package/dist/esm/node_modules/tree-kill/index.js.map +0 -1
- package/dist/esm/packages/shared-lib-node/src/exists.js.map +0 -1
- package/dist/esm/packages/shared-lib-node/src/spawn.js +0 -2
- package/dist/esm/packages/shared-lib-node/src/spawn.js.map +0 -1
- /package/dist/cjs/{packages/shared-lib-node/src/exists.cjs → exists.cjs} +0 -0
- /package/dist/cjs/{packages/shared-lib-node/src/exists.d.cts → exists.d.cts} +0 -0
- /package/dist/cjs/{packages/shared-lib-node/src/index.cjs → index.cjs} +0 -0
- /package/dist/cjs/{packages/shared-lib-node/src/index.cjs.map → index.cjs.map} +0 -0
- /package/dist/cjs/{packages/shared-lib-node/src/index.d.cts → index.d.cts} +0 -0
- /package/dist/cjs/{packages/shared-lib-node/src/spawn.d.cts → spawn.d.cts} +0 -0
- /package/dist/esm/{packages/shared-lib-node/src/exists.d.ts → exists.d.ts} +0 -0
- /package/dist/esm/{packages/shared-lib-node/src/exists.js → exists.js} +0 -0
- /package/dist/esm/{packages/shared-lib-node/src/index.d.ts → index.d.ts} +0 -0
- /package/dist/esm/{packages/shared-lib-node/src/index.js → index.js} +0 -0
- /package/dist/esm/{packages/shared-lib-node/src/index.js.map → index.js.map} +0 -0
- /package/dist/esm/{packages/shared-lib-node/src/spawn.d.ts → spawn.d.ts} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exists.cjs","sources":["../../src/exists.ts"],"sourcesContent":["import fs from 'node:fs';\n\nexport function existsAsync(filePath: string): Promise<boolean> {\n return new Promise((resolve) => {\n fs.access(filePath, fs.constants.F_OK, (err) => {\n resolve(!err);\n });\n });\n}\n"],"names":["filePath","Promise","resolve","fs","access","constants","F_OK","err"],"mappings":"0DAEO,SAAqBA,GAC1B,OAAO,IAAIC,SAASC,IAClBC,EAAGC,OAAOJ,EAAUG,EAAGE,UAAUC,MAAOC,IACtCL,GAASK,EAAI,GACb,GAEN"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var e=require("node:child_process"),r=require("tree-kill");exports.spawnAsync=async function(s,t,o){return new Promise(((n,i)=>{try{const d=e.spawn(s,t??[],o??{});let c="",p="";o?.input&&(d.stdin?.write(o.input),d.stdin?.end()),d.stdout?.on("data",(e=>{c+=e})),d.stderr?.on("data",(e=>{o?.mergeOutAndError?c+=e:p+=e}));let l=!1;const a=()=>{!l&&d.pid&&(l=!0,o?.verbose&&console.info(`treeKill(${d.pid})`),r(d.pid))};o?.killOnExit&&(process.on("beforeExit",a),process.on("SIGINT",a)),d.on("error",(e=>{process.removeListener("exit",a),d.removeAllListeners("close"),i(e)})),d.on("close",((e,r)=>{process.removeListener("exit",a),void 0===d.pid?i(new Error("Process has no pid.")):n({pid:d.pid,stdout:c,stderr:p,status:e,signal:r})}))}catch(e){i(e)}}))};
|
|
2
|
+
//# sourceMappingURL=spawn.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spawn.cjs","sources":["../../src/spawn.ts"],"sourcesContent":["import type {\n SpawnOptions,\n SpawnOptionsWithoutStdio,\n SpawnOptionsWithStdioTuple,\n SpawnSyncReturns,\n StdioNull,\n StdioPipe,\n} from 'node:child_process';\nimport { spawn } from 'node:child_process';\n\nimport treeKill from 'tree-kill';\n\nexport type SpawnAsyncReturns = Omit<SpawnSyncReturns<string>, 'output' | 'error'>;\n\nexport type SpawnAsyncOptions = (\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) & {\n input?: string;\n mergeOutAndError?: boolean;\n killOnExit?: boolean;\n verbose?: boolean;\n};\n\nexport async function spawnAsync(\n command: string,\n args?: ReadonlyArray<string>,\n options?: SpawnAsyncOptions\n): Promise<SpawnAsyncReturns> {\n return new Promise((resolve, reject) => {\n try {\n const proc = spawn(command, args ?? [], options ?? {});\n let stdout = '';\n let stderr = '';\n\n if (options?.input) {\n proc.stdin?.write(options.input);\n proc.stdin?.end();\n }\n proc.stdout?.on('data', (data) => {\n stdout += data;\n });\n proc.stderr?.on('data', (data) => {\n if (options?.mergeOutAndError) {\n stdout += data;\n } else {\n stderr += data;\n }\n });\n\n let stopped = false;\n const stopProcess = (): void => {\n if (stopped || !proc.pid) return;\n\n stopped = true;\n if (options?.verbose) {\n console.info(`treeKill(${proc.pid})`);\n }\n treeKill(proc.pid);\n };\n if (options?.killOnExit) {\n process.on('beforeExit', stopProcess);\n process.on('SIGINT', stopProcess);\n }\n\n proc.on('error', (error) => {\n process.removeListener('exit', stopProcess);\n proc.removeAllListeners('close');\n reject(error);\n });\n proc.on('close', (code: number | null, signal: NodeJS.Signals | null) => {\n process.removeListener('exit', stopProcess);\n if (proc.pid === undefined) {\n reject(new Error('Process has no pid.'));\n } else {\n resolve({\n pid: proc.pid,\n stdout,\n stderr,\n status: code,\n signal,\n });\n }\n });\n } catch (error) {\n reject(error);\n }\n });\n}\n"],"names":["async","command","args","options","Promise","resolve","reject","proc","spawn","stdout","stderr","input","stdin","write","end","on","data","mergeOutAndError","stopped","stopProcess","pid","verbose","console","info","treeKill","killOnExit","process","error","removeListener","removeAllListeners","code","signal","undefined","Error","status"],"mappings":"2FAgCOA,eACLC,EACAC,EACAC,GAEA,OAAO,IAAIC,SAAQ,CAACC,EAASC,KAC3B,IACE,MAAMC,EAAOC,EAAAA,MAAMP,EAASC,GAAQ,GAAIC,GAAW,CAAA,GACnD,IAAIM,EAAS,GACTC,EAAS,GAETP,GAASQ,QACXJ,EAAKK,OAAOC,MAAMV,EAAQQ,OAC1BJ,EAAKK,OAAOE,OAEdP,EAAKE,QAAQM,GAAG,QAASC,IACvBP,GAAUO,CAAI,IAEhBT,EAAKG,QAAQK,GAAG,QAASC,IACnBb,GAASc,iBACXR,GAAUO,EAEVN,GAAUM,CACZ,IAGF,IAAIE,GAAU,EACd,MAAMC,EAAcA,MACdD,GAAYX,EAAKa,MAErBF,GAAU,EACNf,GAASkB,SACXC,QAAQC,KAAM,YAAWhB,EAAKa,QAEhCI,EAASjB,EAAKa,KAAI,EAEhBjB,GAASsB,aACXC,QAAQX,GAAG,aAAcI,GACzBO,QAAQX,GAAG,SAAUI,IAGvBZ,EAAKQ,GAAG,SAAUY,IAChBD,QAAQE,eAAe,OAAQT,GAC/BZ,EAAKsB,mBAAmB,SACxBvB,EAAOqB,EAAM,IAEfpB,EAAKQ,GAAG,SAAS,CAACe,EAAqBC,KACrCL,QAAQE,eAAe,OAAQT,QACda,IAAbzB,EAAKa,IACPd,EAAO,IAAI2B,MAAM,wBAEjB5B,EAAQ,CACNe,IAAKb,EAAKa,IACVX,SACAC,SACAwB,OAAQJ,EACRC,UAEJ,GAEH,CAAC,MAAOJ,GACPrB,EAAOqB,EACT,IAEJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exists.js","sources":["../../src/exists.ts"],"sourcesContent":["import fs from 'node:fs';\n\nexport function existsAsync(filePath: string): Promise<boolean> {\n return new Promise((resolve) => {\n fs.access(filePath, fs.constants.F_OK, (err) => {\n resolve(!err);\n });\n });\n}\n"],"names":["existsAsync","filePath","Promise","resolve","fs","access","constants","F_OK","err"],"mappings":"uBAEO,SAASA,EAAYC,GAC1B,OAAO,IAAIC,SAASC,IAClBC,EAAGC,OAAOJ,EAAUG,EAAGE,UAAUC,MAAOC,IACtCL,GAASK,EAAI,GACb,GAEN"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{spawn as e}from"node:child_process";import r from"tree-kill";async function o(o,t,s){return new Promise(((i,n)=>{try{const d=e(o,t??[],s??{});let p="",c="";s?.input&&(d.stdin?.write(s.input),d.stdin?.end()),d.stdout?.on("data",(e=>{p+=e})),d.stderr?.on("data",(e=>{s?.mergeOutAndError?p+=e:c+=e}));let l=!1;const a=()=>{!l&&d.pid&&(l=!0,s?.verbose&&console.info(`treeKill(${d.pid})`),r(d.pid))};s?.killOnExit&&(process.on("beforeExit",a),process.on("SIGINT",a)),d.on("error",(e=>{process.removeListener("exit",a),d.removeAllListeners("close"),n(e)})),d.on("close",((e,r)=>{process.removeListener("exit",a),void 0===d.pid?n(new Error("Process has no pid.")):i({pid:d.pid,stdout:p,stderr:c,status:e,signal:r})}))}catch(e){n(e)}}))}export{o as spawnAsync};
|
|
2
|
+
//# sourceMappingURL=spawn.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spawn.js","sources":["../../src/spawn.ts"],"sourcesContent":["import type {\n SpawnOptions,\n SpawnOptionsWithoutStdio,\n SpawnOptionsWithStdioTuple,\n SpawnSyncReturns,\n StdioNull,\n StdioPipe,\n} from 'node:child_process';\nimport { spawn } from 'node:child_process';\n\nimport treeKill from 'tree-kill';\n\nexport type SpawnAsyncReturns = Omit<SpawnSyncReturns<string>, 'output' | 'error'>;\n\nexport type SpawnAsyncOptions = (\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) & {\n input?: string;\n mergeOutAndError?: boolean;\n killOnExit?: boolean;\n verbose?: boolean;\n};\n\nexport async function spawnAsync(\n command: string,\n args?: ReadonlyArray<string>,\n options?: SpawnAsyncOptions\n): Promise<SpawnAsyncReturns> {\n return new Promise((resolve, reject) => {\n try {\n const proc = spawn(command, args ?? [], options ?? {});\n let stdout = '';\n let stderr = '';\n\n if (options?.input) {\n proc.stdin?.write(options.input);\n proc.stdin?.end();\n }\n proc.stdout?.on('data', (data) => {\n stdout += data;\n });\n proc.stderr?.on('data', (data) => {\n if (options?.mergeOutAndError) {\n stdout += data;\n } else {\n stderr += data;\n }\n });\n\n let stopped = false;\n const stopProcess = (): void => {\n if (stopped || !proc.pid) return;\n\n stopped = true;\n if (options?.verbose) {\n console.info(`treeKill(${proc.pid})`);\n }\n treeKill(proc.pid);\n };\n if (options?.killOnExit) {\n process.on('beforeExit', stopProcess);\n process.on('SIGINT', stopProcess);\n }\n\n proc.on('error', (error) => {\n process.removeListener('exit', stopProcess);\n proc.removeAllListeners('close');\n reject(error);\n });\n proc.on('close', (code: number | null, signal: NodeJS.Signals | null) => {\n process.removeListener('exit', stopProcess);\n if (proc.pid === undefined) {\n reject(new Error('Process has no pid.'));\n } else {\n resolve({\n pid: proc.pid,\n stdout,\n stderr,\n status: code,\n signal,\n });\n }\n });\n } catch (error) {\n reject(error);\n }\n });\n}\n"],"names":["async","spawnAsync","command","args","options","Promise","resolve","reject","proc","spawn","stdout","stderr","input","stdin","write","end","on","data","mergeOutAndError","stopped","stopProcess","pid","verbose","console","info","treeKill","killOnExit","process","error","removeListener","removeAllListeners","code","signal","undefined","Error","status"],"mappings":"oEAgCOA,eAAeC,EACpBC,EACAC,EACAC,GAEA,OAAO,IAAIC,SAAQ,CAACC,EAASC,KAC3B,IACE,MAAMC,EAAOC,EAAMP,EAASC,GAAQ,GAAIC,GAAW,CAAA,GACnD,IAAIM,EAAS,GACTC,EAAS,GAETP,GAASQ,QACXJ,EAAKK,OAAOC,MAAMV,EAAQQ,OAC1BJ,EAAKK,OAAOE,OAEdP,EAAKE,QAAQM,GAAG,QAASC,IACvBP,GAAUO,CAAI,IAEhBT,EAAKG,QAAQK,GAAG,QAASC,IACnBb,GAASc,iBACXR,GAAUO,EAEVN,GAAUM,CACZ,IAGF,IAAIE,GAAU,EACd,MAAMC,EAAcA,MACdD,GAAYX,EAAKa,MAErBF,GAAU,EACNf,GAASkB,SACXC,QAAQC,KAAM,YAAWhB,EAAKa,QAEhCI,EAASjB,EAAKa,KAAI,EAEhBjB,GAASsB,aACXC,QAAQX,GAAG,aAAcI,GACzBO,QAAQX,GAAG,SAAUI,IAGvBZ,EAAKQ,GAAG,SAAUY,IAChBD,QAAQE,eAAe,OAAQT,GAC/BZ,EAAKsB,mBAAmB,SACxBvB,EAAOqB,EAAM,IAEfpB,EAAKQ,GAAG,SAAS,CAACe,EAAqBC,KACrCL,QAAQE,eAAe,OAAQT,QACda,IAAbzB,EAAKa,IACPd,EAAO,IAAI2B,MAAM,wBAEjB5B,EAAQ,CACNe,IAAKb,EAAKa,IACVX,SACAC,SACAwB,OAAQJ,EACRC,UAEJ,GAEH,CAAC,MAAOJ,GACPrB,EAAOqB,EACT,IAEJ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@willbooster/shared-lib-node",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"author": "WillBooster Inc.",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -35,28 +35,31 @@
|
|
|
35
35
|
"typecheck": "tsc --noEmit --Pretty"
|
|
36
36
|
},
|
|
37
37
|
"prettier": "@willbooster/prettier-config",
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"tree-kill": "1.2.2"
|
|
40
|
+
},
|
|
38
41
|
"devDependencies": {
|
|
39
|
-
"@types/eslint": "8.
|
|
42
|
+
"@types/eslint": "8.44.0",
|
|
40
43
|
"@types/micromatch": "4.0.2",
|
|
41
44
|
"@types/prettier": "2.7.3",
|
|
42
|
-
"@typescript-eslint/eslint-plugin": "
|
|
43
|
-
"@typescript-eslint/parser": "
|
|
45
|
+
"@typescript-eslint/eslint-plugin": "6.0.0",
|
|
46
|
+
"@typescript-eslint/parser": "6.0.0",
|
|
44
47
|
"@willbooster/eslint-config-ts": "10.2.0",
|
|
45
48
|
"@willbooster/prettier-config": "9.1.1",
|
|
46
|
-
"build-ts": "
|
|
47
|
-
"eslint": "8.
|
|
49
|
+
"build-ts": "7.0.0",
|
|
50
|
+
"eslint": "8.44.0",
|
|
48
51
|
"eslint-config-prettier": "8.8.0",
|
|
49
52
|
"eslint-import-resolver-typescript": "3.5.5",
|
|
50
53
|
"eslint-plugin-import": "2.27.5",
|
|
51
54
|
"eslint-plugin-sort-class-members": "1.18.0",
|
|
52
55
|
"eslint-plugin-sort-destructure-keys": "1.5.0",
|
|
53
56
|
"eslint-plugin-unicorn": "47.0.0",
|
|
54
|
-
"lint-staged": "13.2.
|
|
57
|
+
"lint-staged": "13.2.3",
|
|
55
58
|
"micromatch": "4.0.5",
|
|
56
|
-
"prettier": "
|
|
57
|
-
"sort-package-json": "2.
|
|
58
|
-
"typescript": "5.1.
|
|
59
|
-
"vitest": "0.
|
|
59
|
+
"prettier": "3.0.0",
|
|
60
|
+
"sort-package-json": "2.5.1",
|
|
61
|
+
"typescript": "5.1.6",
|
|
62
|
+
"vitest": "0.33.0"
|
|
60
63
|
},
|
|
61
64
|
"publishConfig": {
|
|
62
65
|
"access": "public"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"_commonjsHelpers.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";var r=require("../../_virtual/_commonjsHelpers.cjs"),t=require("node:child_process"),e=t.spawn,n=t.exec,o=function(r,t,o){if("function"==typeof t&&void 0===o&&(o=t,t=void 0),r=parseInt(r),Number.isNaN(r)){if(o)return o(new Error("pid must be a number"));throw new Error("pid must be a number")}var c={},a={};switch(c[r]=[],a[r]=1,process.platform){case"win32":n("taskkill /pid "+r+" /T /F",o);break;case"darwin":u(r,c,a,(function(r){return e("pgrep",["-P",r])}),(function(){i(c,t,o)}));break;default:u(r,c,a,(function(r){return e("ps",["-o","pid","--no-headers","--ppid",r])}),(function(){i(c,t,o)}))}};function i(r,t,e){var n={};try{Object.keys(r).forEach((function(e){r[e].forEach((function(r){n[r]||(c(r,t),n[r]=1)})),n[e]||(c(e,t),n[e]=1)}))}catch(r){if(e)return e(r);throw r}if(e)return e()}function c(r,t){try{process.kill(parseInt(r,10),t)}catch(r){if("ESRCH"!==r.code)throw r}}function u(r,t,e,n,o){var i=n(r),c="";i.stdout.on("data",(function(r){r=r.toString("ascii");c+=r}));i.on("close",(function(i){delete e[r],0==i?c.match(/\d+/g).forEach((function(i){i=parseInt(i,10),t[r].push(i),t[i]=[],e[i]=1,u(i,t,e,n,o)})):0==Object.keys(e).length&&o()}))}var a=r.getDefaultExportFromCjs(o);module.exports=a;
|
|
2
|
-
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../../../../../node_modules/tree-kill/index.js"],"sourcesContent":["'use strict';\n\nvar childProcess = require('child_process');\nvar spawn = childProcess.spawn;\nvar exec = childProcess.exec;\n\nmodule.exports = function (pid, signal, callback) {\n if (typeof signal === 'function' && callback === undefined) {\n callback = signal;\n signal = undefined;\n }\n\n pid = parseInt(pid);\n if (Number.isNaN(pid)) {\n if (callback) {\n return callback(new Error(\"pid must be a number\"));\n } else {\n throw new Error(\"pid must be a number\");\n }\n }\n\n var tree = {};\n var pidsToProcess = {};\n tree[pid] = [];\n pidsToProcess[pid] = 1;\n\n switch (process.platform) {\n case 'win32':\n exec('taskkill /pid ' + pid + ' /T /F', callback);\n break;\n case 'darwin':\n buildProcessTree(pid, tree, pidsToProcess, function (parentPid) {\n return spawn('pgrep', ['-P', parentPid]);\n }, function () {\n killAll(tree, signal, callback);\n });\n break;\n // case 'sunos':\n // buildProcessTreeSunOS(pid, tree, pidsToProcess, function () {\n // killAll(tree, signal, callback);\n // });\n // break;\n default: // Linux\n buildProcessTree(pid, tree, pidsToProcess, function (parentPid) {\n return spawn('ps', ['-o', 'pid', '--no-headers', '--ppid', parentPid]);\n }, function () {\n killAll(tree, signal, callback);\n });\n break;\n }\n};\n\nfunction killAll (tree, signal, callback) {\n var killed = {};\n try {\n Object.keys(tree).forEach(function (pid) {\n tree[pid].forEach(function (pidpid) {\n if (!killed[pidpid]) {\n killPid(pidpid, signal);\n killed[pidpid] = 1;\n }\n });\n if (!killed[pid]) {\n killPid(pid, signal);\n killed[pid] = 1;\n }\n });\n } catch (err) {\n if (callback) {\n return callback(err);\n } else {\n throw err;\n }\n }\n if (callback) {\n return callback();\n }\n}\n\nfunction killPid(pid, signal) {\n try {\n process.kill(parseInt(pid, 10), signal);\n }\n catch (err) {\n if (err.code !== 'ESRCH') throw err;\n }\n}\n\nfunction buildProcessTree (parentPid, tree, pidsToProcess, spawnChildProcessesList, cb) {\n var ps = spawnChildProcessesList(parentPid);\n var allData = '';\n ps.stdout.on('data', function (data) {\n var data = data.toString('ascii');\n allData += data;\n });\n\n var onClose = function (code) {\n delete pidsToProcess[parentPid];\n\n if (code != 0) {\n // no more parent processes\n if (Object.keys(pidsToProcess).length == 0) {\n cb();\n }\n return;\n }\n\n allData.match(/\\d+/g).forEach(function (pid) {\n pid = parseInt(pid, 10);\n tree[parentPid].push(pid);\n tree[pid] = [];\n pidsToProcess[pid] = 1;\n buildProcessTree(pid, tree, pidsToProcess, spawnChildProcessesList, cb);\n });\n };\n\n ps.on('close', onClose);\n}\n"],"names":["childProcess","spawn","exec","treeKill","pid","signal","callback","undefined","parseInt","Number","isNaN","Error","tree","pidsToProcess","process","platform","buildProcessTree","parentPid","killAll","killed","Object","keys","forEach","pidpid","killPid","err","kill","code","spawnChildProcessesList","cb","ps","allData","stdout","on","data","toString","match","push","length"],"mappings":"kEAEIA,gCACAC,EAAQD,EAAaC,MACrBC,EAAOF,EAAaE,KAExBC,EAAiB,SAAUC,EAAKC,EAAQC,GAOpC,GANsB,mBAAXD,QAAsCE,IAAbD,IAChCA,EAAWD,EACXA,OAASE,GAGbH,EAAMI,SAASJ,GACXK,OAAOC,MAAMN,GAAM,CACnB,GAAIE,EACA,OAAOA,EAAS,IAAIK,MAAM,yBAE1B,MAAM,IAAIA,MAAM,uBAEvB,CAED,IAAIC,EAAO,CAAA,EACPC,EAAgB,CAAA,EAIpB,OAHAD,EAAKR,GAAO,GACZS,EAAcT,GAAO,EAEbU,QAAQC,UAChB,IAAK,QACDb,EAAK,iBAAmBE,EAAM,SAAUE,GACxC,MACJ,IAAK,SACDU,EAAiBZ,EAAKQ,EAAMC,GAAe,SAAUI,GACnD,OAAOhB,EAAM,QAAS,CAAC,KAAMgB,GACvC,IAAW,WACCC,EAAQN,EAAMP,EAAQC,EAClC,IACQ,MAMJ,QACIU,EAAiBZ,EAAKQ,EAAMC,GAAe,SAAUI,GACnD,OAAOhB,EAAM,KAAM,CAAC,KAAM,MAAO,eAAgB,SAAUgB,GACrE,IAAW,WACCC,EAAQN,EAAMP,EAAQC,EAClC,IAGA,EAEA,SAASY,EAASN,EAAMP,EAAQC,GAC5B,IAAIa,EAAS,CAAA,EACb,IACIC,OAAOC,KAAKT,GAAMU,SAAQ,SAAUlB,GAChCQ,EAAKR,GAAKkB,SAAQ,SAAUC,GACnBJ,EAAOI,KACRC,EAAQD,EAAQlB,GAChBc,EAAOI,GAAU,EAErC,IACiBJ,EAAOf,KACRoB,EAAQpB,EAAKC,GACbc,EAAOf,GAAO,EAE9B,GACK,CAAC,MAAOqB,GACL,GAAInB,EACA,OAAOA,EAASmB,GAEhB,MAAMA,CAEb,CACD,GAAInB,EACA,OAAOA,GAEf,CAEA,SAASkB,EAAQpB,EAAKC,GAClB,IACIS,QAAQY,KAAKlB,SAASJ,EAAK,IAAKC,EACnC,CACD,MAAOoB,GACH,GAAiB,UAAbA,EAAIE,KAAkB,MAAMF,CACnC,CACL,CAEA,SAAST,EAAkBC,EAAWL,EAAMC,EAAee,EAAyBC,GAChF,IAAIC,EAAKF,EAAwBX,GAC7Bc,EAAU,GACdD,EAAGE,OAAOC,GAAG,QAAQ,SAAUC,GACvBA,EAAOA,EAAKC,SAAS,SACzBJ,GAAWG,CACnB,IAsBIJ,EAAGG,GAAG,SApBQ,SAAUN,UACbd,EAAcI,GAET,GAARU,EAQJI,EAAQK,MAAM,QAAQd,SAAQ,SAAUlB,GACtCA,EAAMI,SAASJ,EAAK,IACpBQ,EAAKK,GAAWoB,KAAKjC,GACrBQ,EAAKR,GAAO,GACZS,EAAcT,GAAO,EACrBY,EAAiBZ,EAAKQ,EAAMC,EAAee,EAAyBC,EAC9E,IAZqD,GAArCT,OAAOC,KAAKR,GAAeyB,QAC3BT,MAehB","x_google_ignoreList":[0]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"exists.cjs","sources":["../../../../../src/exists.ts"],"sourcesContent":["import fs from 'node:fs';\n\nexport function existsAsync(filePath: string): Promise<boolean> {\n return new Promise((resolve) => {\n fs.access(filePath, fs.constants.F_OK, (err) => {\n resolve(!err);\n });\n });\n}\n"],"names":["filePath","Promise","resolve","fs","access","constants","F_OK","err"],"mappings":"0DAEO,SAAqBA,GAC1B,OAAO,IAAIC,SAASC,IAClBC,EAAGC,OAAOJ,EAAUG,EAAGE,UAAUC,MAAOC,IACtCL,GAASK,EAAI,GACb,GAEN"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";var e=require("node:child_process"),r=require("../../../node_modules/tree-kill/index.cjs");exports.spawnAsync=async function(s,o,t){return new Promise(((n,i)=>{try{const d=e.spawn(s,o??[],t??{});let c="",p="";t?.input&&(d.stdin?.write(t.input),d.stdin?.end()),d.stdout?.on("data",(e=>{c+=e})),d.stderr?.on("data",(e=>{t?.mergeOutAndError?c+=e:p+=e}));let l=!1;const a=()=>{!l&&d.pid&&(l=!0,t?.verbose&&console.info(`treeKill(${d.pid})`),r(d.pid))};t?.killOnExit&&(process.on("beforeExit",a),process.on("SIGINT",a)),d.on("error",(e=>{process.removeListener("exit",a),d.removeAllListeners("close"),i(e)})),d.on("close",((e,r)=>{process.removeListener("exit",a),void 0===d.pid?i(new Error("Process has no pid.")):n({pid:d.pid,stdout:c,stderr:p,status:e,signal:r})}))}catch(e){i(e)}}))};
|
|
2
|
-
//# sourceMappingURL=spawn.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"spawn.cjs","sources":["../../../../../src/spawn.ts"],"sourcesContent":["import type {\n SpawnOptions,\n SpawnOptionsWithoutStdio,\n SpawnOptionsWithStdioTuple,\n SpawnSyncReturns,\n StdioNull,\n StdioPipe,\n} from 'node:child_process';\nimport { spawn } from 'node:child_process';\n\nimport treeKill from 'tree-kill';\n\nexport type SpawnAsyncReturns = Omit<SpawnSyncReturns<string>, 'output' | 'error'>;\n\nexport type SpawnAsyncOptions = (\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) & {\n input?: string;\n mergeOutAndError?: boolean;\n killOnExit?: boolean;\n verbose?: boolean;\n};\n\nexport async function spawnAsync(\n command: string,\n args?: ReadonlyArray<string>,\n options?: SpawnAsyncOptions\n): Promise<SpawnAsyncReturns> {\n return new Promise((resolve, reject) => {\n try {\n const proc = spawn(command, args ?? [], options ?? {});\n let stdout = '';\n let stderr = '';\n\n if (options?.input) {\n proc.stdin?.write(options.input);\n proc.stdin?.end();\n }\n proc.stdout?.on('data', (data) => {\n stdout += data;\n });\n proc.stderr?.on('data', (data) => {\n if (options?.mergeOutAndError) {\n stdout += data;\n } else {\n stderr += data;\n }\n });\n\n let stopped = false;\n const stopProcess = (): void => {\n if (stopped || !proc.pid) return;\n\n stopped = true;\n if (options?.verbose) {\n console.info(`treeKill(${proc.pid})`);\n }\n treeKill(proc.pid);\n };\n if (options?.killOnExit) {\n process.on('beforeExit', stopProcess);\n process.on('SIGINT', stopProcess);\n }\n\n proc.on('error', (error) => {\n process.removeListener('exit', stopProcess);\n proc.removeAllListeners('close');\n reject(error);\n });\n proc.on('close', (code: number | null, signal: NodeJS.Signals | null) => {\n process.removeListener('exit', stopProcess);\n if (proc.pid === undefined) {\n reject(new Error('Process has no pid.'));\n } else {\n resolve({\n pid: proc.pid,\n stdout,\n stderr,\n status: code,\n signal,\n });\n }\n });\n } catch (error) {\n reject(error);\n }\n });\n}\n"],"names":["async","command","args","options","Promise","resolve","reject","proc","spawn","stdout","stderr","input","stdin","write","end","on","data","mergeOutAndError","stopped","stopProcess","pid","verbose","console","info","treeKill","killOnExit","process","error","removeListener","removeAllListeners","code","signal","undefined","Error","status"],"mappings":"2HAgCOA,eACLC,EACAC,EACAC,GAEA,OAAO,IAAIC,SAAQ,CAACC,EAASC,KAC3B,IACE,MAAMC,EAAOC,EAAAA,MAAMP,EAASC,GAAQ,GAAIC,GAAW,CAAA,GACnD,IAAIM,EAAS,GACTC,EAAS,GAETP,GAASQ,QACXJ,EAAKK,OAAOC,MAAMV,EAAQQ,OAC1BJ,EAAKK,OAAOE,OAEdP,EAAKE,QAAQM,GAAG,QAASC,IACvBP,GAAUO,CAAI,IAEhBT,EAAKG,QAAQK,GAAG,QAASC,IACnBb,GAASc,iBACXR,GAAUO,EAEVN,GAAUM,CACZ,IAGF,IAAIE,GAAU,EACd,MAAMC,EAAcA,MACdD,GAAYX,EAAKa,MAErBF,GAAU,EACNf,GAASkB,SACXC,QAAQC,KAAM,YAAWhB,EAAKa,QAEhCI,EAASjB,EAAKa,KAAI,EAEhBjB,GAASsB,aACXC,QAAQX,GAAG,aAAcI,GACzBO,QAAQX,GAAG,SAAUI,IAGvBZ,EAAKQ,GAAG,SAAUY,IAChBD,QAAQE,eAAe,OAAQT,GAC/BZ,EAAKsB,mBAAmB,SACxBvB,EAAOqB,EAAM,IAEfpB,EAAKQ,GAAG,SAAS,CAACe,EAAqBC,KACrCL,QAAQE,eAAe,OAAQT,QACda,IAAbzB,EAAKa,IACPd,EAAO,IAAI2B,MAAM,wBAEjB5B,EAAQ,CACNe,IAAKb,EAAKa,IACVX,SACAC,SACAwB,OAAQJ,EACRC,UAEJ,GAEH,CAAC,MAAOJ,GACPrB,EAAOqB,EACT,IAEJ"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"_commonjsHelpers.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{getDefaultExportFromCjs as r}from"../../_virtual/_commonjsHelpers.js";import t from"node:child_process";var n=t,o=n.spawn,e=n.exec;function i(r,t,n){var o={};try{Object.keys(r).forEach((function(n){r[n].forEach((function(r){o[r]||(c(r,t),o[r]=1)})),o[n]||(c(n,t),o[n]=1)}))}catch(r){if(n)return n(r);throw r}if(n)return n()}function c(r,t){try{process.kill(parseInt(r,10),t)}catch(r){if("ESRCH"!==r.code)throw r}}function a(r,t,n,o,e){var i=o(r),c="";i.stdout.on("data",(function(r){r=r.toString("ascii");c+=r}));i.on("close",(function(i){delete n[r],0==i?c.match(/\d+/g).forEach((function(i){i=parseInt(i,10),t[r].push(i),t[i]=[],n[i]=1,a(i,t,n,o,e)})):0==Object.keys(n).length&&e()}))}var s=r((function(r,t,n){if("function"==typeof t&&void 0===n&&(n=t,t=void 0),r=parseInt(r),Number.isNaN(r)){if(n)return n(new Error("pid must be a number"));throw new Error("pid must be a number")}var c={},s={};switch(c[r]=[],s[r]=1,process.platform){case"win32":e("taskkill /pid "+r+" /T /F",n);break;case"darwin":a(r,c,s,(function(r){return o("pgrep",["-P",r])}),(function(){i(c,t,n)}));break;default:a(r,c,s,(function(r){return o("ps",["-o","pid","--no-headers","--ppid",r])}),(function(){i(c,t,n)}))}}));export{s as default};
|
|
2
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../../node_modules/tree-kill/index.js"],"sourcesContent":["'use strict';\n\nvar childProcess = require('child_process');\nvar spawn = childProcess.spawn;\nvar exec = childProcess.exec;\n\nmodule.exports = function (pid, signal, callback) {\n if (typeof signal === 'function' && callback === undefined) {\n callback = signal;\n signal = undefined;\n }\n\n pid = parseInt(pid);\n if (Number.isNaN(pid)) {\n if (callback) {\n return callback(new Error(\"pid must be a number\"));\n } else {\n throw new Error(\"pid must be a number\");\n }\n }\n\n var tree = {};\n var pidsToProcess = {};\n tree[pid] = [];\n pidsToProcess[pid] = 1;\n\n switch (process.platform) {\n case 'win32':\n exec('taskkill /pid ' + pid + ' /T /F', callback);\n break;\n case 'darwin':\n buildProcessTree(pid, tree, pidsToProcess, function (parentPid) {\n return spawn('pgrep', ['-P', parentPid]);\n }, function () {\n killAll(tree, signal, callback);\n });\n break;\n // case 'sunos':\n // buildProcessTreeSunOS(pid, tree, pidsToProcess, function () {\n // killAll(tree, signal, callback);\n // });\n // break;\n default: // Linux\n buildProcessTree(pid, tree, pidsToProcess, function (parentPid) {\n return spawn('ps', ['-o', 'pid', '--no-headers', '--ppid', parentPid]);\n }, function () {\n killAll(tree, signal, callback);\n });\n break;\n }\n};\n\nfunction killAll (tree, signal, callback) {\n var killed = {};\n try {\n Object.keys(tree).forEach(function (pid) {\n tree[pid].forEach(function (pidpid) {\n if (!killed[pidpid]) {\n killPid(pidpid, signal);\n killed[pidpid] = 1;\n }\n });\n if (!killed[pid]) {\n killPid(pid, signal);\n killed[pid] = 1;\n }\n });\n } catch (err) {\n if (callback) {\n return callback(err);\n } else {\n throw err;\n }\n }\n if (callback) {\n return callback();\n }\n}\n\nfunction killPid(pid, signal) {\n try {\n process.kill(parseInt(pid, 10), signal);\n }\n catch (err) {\n if (err.code !== 'ESRCH') throw err;\n }\n}\n\nfunction buildProcessTree (parentPid, tree, pidsToProcess, spawnChildProcessesList, cb) {\n var ps = spawnChildProcessesList(parentPid);\n var allData = '';\n ps.stdout.on('data', function (data) {\n var data = data.toString('ascii');\n allData += data;\n });\n\n var onClose = function (code) {\n delete pidsToProcess[parentPid];\n\n if (code != 0) {\n // no more parent processes\n if (Object.keys(pidsToProcess).length == 0) {\n cb();\n }\n return;\n }\n\n allData.match(/\\d+/g).forEach(function (pid) {\n pid = parseInt(pid, 10);\n tree[parentPid].push(pid);\n tree[pid] = [];\n pidsToProcess[pid] = 1;\n buildProcessTree(pid, tree, pidsToProcess, spawnChildProcessesList, cb);\n });\n };\n\n ps.on('close', onClose);\n}\n"],"names":["childProcess","require$$0","spawn","exec","killAll","tree","signal","callback","killed","Object","keys","forEach","pid","pidpid","killPid","err","process","kill","parseInt","code","buildProcessTree","parentPid","pidsToProcess","spawnChildProcessesList","cb","ps","allData","stdout","on","data","toString","match","push","length","undefined","Number","isNaN","Error","platform"],"mappings":"+GAEA,IAAIA,EAAeC,EACfC,EAAQF,EAAaE,MACrBC,EAAOH,EAAaG,KAgDxB,SAASC,EAASC,EAAMC,EAAQC,GAC5B,IAAIC,EAAS,CAAA,EACb,IACIC,OAAOC,KAAKL,GAAMM,SAAQ,SAAUC,GAChCP,EAAKO,GAAKD,SAAQ,SAAUE,GACnBL,EAAOK,KACRC,EAAQD,EAAQP,GAChBE,EAAOK,GAAU,EAErC,IACiBL,EAAOI,KACRE,EAAQF,EAAKN,GACbE,EAAOI,GAAO,EAE9B,GACK,CAAC,MAAOG,GACL,GAAIR,EACA,OAAOA,EAASQ,GAEhB,MAAMA,CAEb,CACD,GAAIR,EACA,OAAOA,GAEf,CAEA,SAASO,EAAQF,EAAKN,GAClB,IACIU,QAAQC,KAAKC,SAASN,EAAK,IAAKN,EACnC,CACD,MAAOS,GACH,GAAiB,UAAbA,EAAII,KAAkB,MAAMJ,CACnC,CACL,CAEA,SAASK,EAAkBC,EAAWhB,EAAMiB,EAAeC,EAAyBC,GAChF,IAAIC,EAAKF,EAAwBF,GAC7BK,EAAU,GACdD,EAAGE,OAAOC,GAAG,QAAQ,SAAUC,GACvBA,EAAOA,EAAKC,SAAS,SACzBJ,GAAWG,CACnB,IAsBIJ,EAAGG,GAAG,SApBQ,SAAUT,UACbG,EAAcD,GAET,GAARF,EAQJO,EAAQK,MAAM,QAAQpB,SAAQ,SAAUC,GACtCA,EAAMM,SAASN,EAAK,IACpBP,EAAKgB,GAAWW,KAAKpB,GACrBP,EAAKO,GAAO,GACZU,EAAcV,GAAO,EACrBQ,EAAiBR,EAAKP,EAAMiB,EAAeC,EAAyBC,EAC9E,IAZqD,GAArCf,OAAOC,KAAKY,GAAeW,QAC3BT,MAehB,UA/GiB,SAAUZ,EAAKN,EAAQC,GAOpC,GANsB,mBAAXD,QAAsC4B,IAAb3B,IAChCA,EAAWD,EACXA,OAAS4B,GAGbtB,EAAMM,SAASN,GACXuB,OAAOC,MAAMxB,GAAM,CACnB,GAAIL,EACA,OAAOA,EAAS,IAAI8B,MAAM,yBAE1B,MAAM,IAAIA,MAAM,uBAEvB,CAED,IAAIhC,EAAO,CAAA,EACPiB,EAAgB,CAAA,EAIpB,OAHAjB,EAAKO,GAAO,GACZU,EAAcV,GAAO,EAEbI,QAAQsB,UAChB,IAAK,QACDnC,EAAK,iBAAmBS,EAAM,SAAUL,GACxC,MACJ,IAAK,SACDa,EAAiBR,EAAKP,EAAMiB,GAAe,SAAUD,GACnD,OAAOnB,EAAM,QAAS,CAAC,KAAMmB,GACvC,IAAW,WACCjB,EAAQC,EAAMC,EAAQC,EAClC,IACQ,MAMJ,QACIa,EAAiBR,EAAKP,EAAMiB,GAAe,SAAUD,GACnD,OAAOnB,EAAM,KAAM,CAAC,KAAM,MAAO,eAAgB,SAAUmB,GACrE,IAAW,WACCjB,EAAQC,EAAMC,EAAQC,EAClC,IAGA","x_google_ignoreList":[0]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"exists.js","sources":["../../../../../src/exists.ts"],"sourcesContent":["import fs from 'node:fs';\n\nexport function existsAsync(filePath: string): Promise<boolean> {\n return new Promise((resolve) => {\n fs.access(filePath, fs.constants.F_OK, (err) => {\n resolve(!err);\n });\n });\n}\n"],"names":["existsAsync","filePath","Promise","resolve","fs","access","constants","F_OK","err"],"mappings":"uBAEO,SAASA,EAAYC,GAC1B,OAAO,IAAIC,SAASC,IAClBC,EAAGC,OAAOJ,EAAUG,EAAGE,UAAUC,MAAOC,IACtCL,GAASK,EAAI,GACb,GAEN"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{spawn as e}from"node:child_process";import o from"../../../node_modules/tree-kill/index.js";async function r(r,s,t){return new Promise(((i,n)=>{try{const d=e(r,s??[],t??{});let p="",c="";t?.input&&(d.stdin?.write(t.input),d.stdin?.end()),d.stdout?.on("data",(e=>{p+=e})),d.stderr?.on("data",(e=>{t?.mergeOutAndError?p+=e:c+=e}));let l=!1;const m=()=>{!l&&d.pid&&(l=!0,t?.verbose&&console.info(`treeKill(${d.pid})`),o(d.pid))};t?.killOnExit&&(process.on("beforeExit",m),process.on("SIGINT",m)),d.on("error",(e=>{process.removeListener("exit",m),d.removeAllListeners("close"),n(e)})),d.on("close",((e,o)=>{process.removeListener("exit",m),void 0===d.pid?n(new Error("Process has no pid.")):i({pid:d.pid,stdout:p,stderr:c,status:e,signal:o})}))}catch(e){n(e)}}))}export{r as spawnAsync};
|
|
2
|
-
//# sourceMappingURL=spawn.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"spawn.js","sources":["../../../../../src/spawn.ts"],"sourcesContent":["import type {\n SpawnOptions,\n SpawnOptionsWithoutStdio,\n SpawnOptionsWithStdioTuple,\n SpawnSyncReturns,\n StdioNull,\n StdioPipe,\n} from 'node:child_process';\nimport { spawn } from 'node:child_process';\n\nimport treeKill from 'tree-kill';\n\nexport type SpawnAsyncReturns = Omit<SpawnSyncReturns<string>, 'output' | 'error'>;\n\nexport type SpawnAsyncOptions = (\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) & {\n input?: string;\n mergeOutAndError?: boolean;\n killOnExit?: boolean;\n verbose?: boolean;\n};\n\nexport async function spawnAsync(\n command: string,\n args?: ReadonlyArray<string>,\n options?: SpawnAsyncOptions\n): Promise<SpawnAsyncReturns> {\n return new Promise((resolve, reject) => {\n try {\n const proc = spawn(command, args ?? [], options ?? {});\n let stdout = '';\n let stderr = '';\n\n if (options?.input) {\n proc.stdin?.write(options.input);\n proc.stdin?.end();\n }\n proc.stdout?.on('data', (data) => {\n stdout += data;\n });\n proc.stderr?.on('data', (data) => {\n if (options?.mergeOutAndError) {\n stdout += data;\n } else {\n stderr += data;\n }\n });\n\n let stopped = false;\n const stopProcess = (): void => {\n if (stopped || !proc.pid) return;\n\n stopped = true;\n if (options?.verbose) {\n console.info(`treeKill(${proc.pid})`);\n }\n treeKill(proc.pid);\n };\n if (options?.killOnExit) {\n process.on('beforeExit', stopProcess);\n process.on('SIGINT', stopProcess);\n }\n\n proc.on('error', (error) => {\n process.removeListener('exit', stopProcess);\n proc.removeAllListeners('close');\n reject(error);\n });\n proc.on('close', (code: number | null, signal: NodeJS.Signals | null) => {\n process.removeListener('exit', stopProcess);\n if (proc.pid === undefined) {\n reject(new Error('Process has no pid.'));\n } else {\n resolve({\n pid: proc.pid,\n stdout,\n stderr,\n status: code,\n signal,\n });\n }\n });\n } catch (error) {\n reject(error);\n }\n });\n}\n"],"names":["async","spawnAsync","command","args","options","Promise","resolve","reject","proc","spawn","stdout","stderr","input","stdin","write","end","on","data","mergeOutAndError","stopped","stopProcess","pid","verbose","console","info","treeKill","killOnExit","process","error","removeListener","removeAllListeners","code","signal","undefined","Error","status"],"mappings":"mGAgCOA,eAAeC,EACpBC,EACAC,EACAC,GAEA,OAAO,IAAIC,SAAQ,CAACC,EAASC,KAC3B,IACE,MAAMC,EAAOC,EAAMP,EAASC,GAAQ,GAAIC,GAAW,CAAA,GACnD,IAAIM,EAAS,GACTC,EAAS,GAETP,GAASQ,QACXJ,EAAKK,OAAOC,MAAMV,EAAQQ,OAC1BJ,EAAKK,OAAOE,OAEdP,EAAKE,QAAQM,GAAG,QAASC,IACvBP,GAAUO,CAAI,IAEhBT,EAAKG,QAAQK,GAAG,QAASC,IACnBb,GAASc,iBACXR,GAAUO,EAEVN,GAAUM,CACZ,IAGF,IAAIE,GAAU,EACd,MAAMC,EAAcA,MACdD,GAAYX,EAAKa,MAErBF,GAAU,EACNf,GAASkB,SACXC,QAAQC,KAAM,YAAWhB,EAAKa,QAEhCI,EAASjB,EAAKa,KAAI,EAEhBjB,GAASsB,aACXC,QAAQX,GAAG,aAAcI,GACzBO,QAAQX,GAAG,SAAUI,IAGvBZ,EAAKQ,GAAG,SAAUY,IAChBD,QAAQE,eAAe,OAAQT,GAC/BZ,EAAKsB,mBAAmB,SACxBvB,EAAOqB,EAAM,IAEfpB,EAAKQ,GAAG,SAAS,CAACe,EAAqBC,KACrCL,QAAQE,eAAe,OAAQT,QACda,IAAbzB,EAAKa,IACPd,EAAO,IAAI2B,MAAM,wBAEjB5B,EAAQ,CACNe,IAAKb,EAAKa,IACVX,SACAC,SACAwB,OAAQJ,EACRC,UAEJ,GAEH,CAAC,MAAOJ,GACPrB,EAAOqB,EACT,IAEJ"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|