@willbooster/shared-lib-node 2.0.1 → 2.0.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 +1 @@
1
- {"version":3,"file":"spawn.cjs","sources":["../../src/spawn.ts"],"sourcesContent":["import {\n spawn,\n SpawnOptions,\n SpawnOptionsWithoutStdio,\n SpawnOptionsWithStdioTuple,\n SpawnSyncReturns,\n StdioNull,\n StdioPipe,\n execSync,\n} from 'node:child_process';\nimport * as os from 'node:os';\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 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 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 const stopProcess = (): void => {\n try {\n let pstreeOutput: string;\n let regex: RegExp;\n if (os.platform() === 'darwin') {\n pstreeOutput = execSync(`pstree ${proc.pid}`).toString();\n regex = /\\d+/;\n } else {\n pstreeOutput = execSync(`pstree -p ${proc.pid}`).toString();\n regex = /\\d+/g;\n }\n const procIds = pstreeOutput.split('\\n').flatMap((line) => (line.match(regex) ?? []).map(Number));\n const descendantProcIds: number[] = [];\n for (const pid of procIds) {\n if (pid > 0 && (pid === proc.pid || descendantProcIds.length > 0)) {\n descendantProcIds.push(pid);\n }\n }\n\n const killScript = `kill ${descendantProcIds.join(' ')}`;\n if (options?.verbose) {\n console.info(pstreeOutput);\n console.info(`$ ${killScript}`);\n }\n execSync(killScript);\n } catch {\n // do nothing.\n }\n };\n if (options?.killOnExit) {\n process.on('exit', 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","on","data","mergeOutAndError","stopProcess","pstreeOutput","regex","os","platform","execSync","pid","toString","procIds","split","flatMap","line","match","map","Number","descendantProcIds","length","push","killScript","join","verbose","console","info","killOnExit","process","error","removeListener","removeAllListeners","code","signal","undefined","Error","status"],"mappings":"mWA+BOA,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,GAEbH,EAAKE,QAAQE,GAAG,QAASC,IACvBH,GAAUG,CAAI,IAEhBL,EAAKG,QAAQC,GAAG,QAASC,IACnBT,GAASU,iBACXJ,GAAUG,EAEVF,GAAUE,CACZ,IAGF,MAAME,EAAcA,KAClB,IACE,IAAIC,EACAC,EACkB,WAAlBC,EAAGC,YACLH,EAAeI,EAAAA,SAAU,UAASZ,EAAKa,OAAOC,WAC9CL,EAAQ,QAERD,EAAeI,EAAAA,SAAU,aAAYZ,EAAKa,OAAOC,WACjDL,EAAQ,QAEV,MAAMM,EAAUP,EAAaQ,MAAM,MAAMC,SAASC,IAAUA,EAAKC,MAAMV,IAAU,IAAIW,IAAIC,UACnFC,EAA8B,GACpC,IAAK,MAAMT,KAAOE,EACZF,EAAM,IAAMA,IAAQb,EAAKa,KAAOS,EAAkBC,OAAS,IAC7DD,EAAkBE,KAAKX,GAI3B,MAAMY,EAAc,QAAOH,EAAkBI,KAAK,OAC9C9B,GAAS+B,UACXC,QAAQC,KAAKrB,GACboB,QAAQC,KAAM,KAAIJ,MAEpBb,EAAQA,SAACa,EACX,CAAE,MACA,GAGA7B,GAASkC,YACXC,QAAQ3B,GAAG,OAAQG,GAGrBP,EAAKI,GAAG,SAAU4B,IAChBD,QAAQE,eAAe,OAAQ1B,GAC/BP,EAAKkC,mBAAmB,SACxBnC,EAAOiC,EAAM,IAEfhC,EAAKI,GAAG,SAAS,CAAC+B,EAAqBC,KACrCL,QAAQE,eAAe,OAAQ1B,QACd8B,IAAbrC,EAAKa,IACPd,EAAO,IAAIuC,MAAM,wBAEjBxC,EAAQ,CACNe,IAAKb,EAAKa,IACVX,SACAC,SACAoC,OAAQJ,EACRC,UAEJ,GAEH,CAAC,MAAOJ,GACPjC,EAAOiC,EACT,IAEJ"}
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, execSync } from 'node:child_process';\nimport * as os from 'node:os';\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 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 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 const stopProcess = (): void => {\n try {\n let pstreeOutput: string;\n let regex: RegExp;\n if (os.platform() === 'darwin') {\n pstreeOutput = execSync(`pstree ${proc.pid}`).toString();\n regex = /\\d+/;\n } else {\n pstreeOutput = execSync(`pstree -p ${proc.pid}`).toString();\n regex = /\\d+/g;\n }\n const procIds = pstreeOutput.split('\\n').flatMap((line) => (line.match(regex) ?? []).map(Number));\n const descendantProcIds: number[] = [];\n for (const pid of procIds) {\n if (pid > 0 && (pid === proc.pid || descendantProcIds.length > 0)) {\n descendantProcIds.push(pid);\n }\n }\n\n const killScript = `kill ${descendantProcIds.join(' ')}`;\n if (options?.verbose) {\n console.info(pstreeOutput);\n console.info(`$ ${killScript}`);\n }\n execSync(killScript);\n } catch {\n // do nothing.\n }\n };\n if (options?.killOnExit) {\n process.on('exit', 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","on","data","mergeOutAndError","stopProcess","pstreeOutput","regex","os","platform","execSync","pid","toString","procIds","split","flatMap","line","match","map","Number","descendantProcIds","length","push","killScript","join","verbose","console","info","killOnExit","process","error","removeListener","removeAllListeners","code","signal","undefined","Error","status"],"mappings":"mWA8BOA,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,GAEbH,EAAKE,QAAQE,GAAG,QAASC,IACvBH,GAAUG,CAAI,IAEhBL,EAAKG,QAAQC,GAAG,QAASC,IACnBT,GAASU,iBACXJ,GAAUG,EAEVF,GAAUE,CACZ,IAGF,MAAME,EAAcA,KAClB,IACE,IAAIC,EACAC,EACkB,WAAlBC,EAAGC,YACLH,EAAeI,EAAAA,SAAU,UAASZ,EAAKa,OAAOC,WAC9CL,EAAQ,QAERD,EAAeI,EAAAA,SAAU,aAAYZ,EAAKa,OAAOC,WACjDL,EAAQ,QAEV,MAAMM,EAAUP,EAAaQ,MAAM,MAAMC,SAASC,IAAUA,EAAKC,MAAMV,IAAU,IAAIW,IAAIC,UACnFC,EAA8B,GACpC,IAAK,MAAMT,KAAOE,EACZF,EAAM,IAAMA,IAAQb,EAAKa,KAAOS,EAAkBC,OAAS,IAC7DD,EAAkBE,KAAKX,GAI3B,MAAMY,EAAc,QAAOH,EAAkBI,KAAK,OAC9C9B,GAAS+B,UACXC,QAAQC,KAAKrB,GACboB,QAAQC,KAAM,KAAIJ,MAEpBb,EAAQA,SAACa,EACX,CAAE,MACA,GAGA7B,GAASkC,YACXC,QAAQ3B,GAAG,OAAQG,GAGrBP,EAAKI,GAAG,SAAU4B,IAChBD,QAAQE,eAAe,OAAQ1B,GAC/BP,EAAKkC,mBAAmB,SACxBnC,EAAOiC,EAAM,IAEfhC,EAAKI,GAAG,SAAS,CAAC+B,EAAqBC,KACrCL,QAAQE,eAAe,OAAQ1B,QACd8B,IAAbrC,EAAKa,IACPd,EAAO,IAAIuC,MAAM,wBAEjBxC,EAAQ,CACNe,IAAKb,EAAKa,IACVX,SACAC,SACAoC,OAAQJ,EACRC,UAEJ,GAEH,CAAC,MAAOJ,GACPjC,EAAOiC,EACT,IAEJ"}
@@ -1,4 +1,4 @@
1
- /// <reference types="glob" />
1
+ /// <reference types="body-parser" />
2
2
  import { SpawnOptions, SpawnOptionsWithoutStdio, SpawnOptionsWithStdioTuple, SpawnSyncReturns, StdioNull, StdioPipe } from 'node:child_process';
3
3
  type SpawnAsyncReturns = Omit<SpawnSyncReturns<string>, 'output' | 'error'>;
4
4
  type SpawnAsyncOptions = (SpawnOptionsWithoutStdio | SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe> | SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioNull> | SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioPipe> | SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe> | SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioNull> | SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioNull> | SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioPipe> | SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioNull> | SpawnOptions) & {
@@ -1,4 +1,4 @@
1
- /// <reference types="glob" />
1
+ /// <reference types="body-parser" />
2
2
  import { SpawnOptions, SpawnOptionsWithoutStdio, SpawnOptionsWithStdioTuple, SpawnSyncReturns, StdioNull, StdioPipe } from 'node:child_process';
3
3
  type SpawnAsyncReturns = Omit<SpawnSyncReturns<string>, 'output' | 'error'>;
4
4
  type SpawnAsyncOptions = (SpawnOptionsWithoutStdio | SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe> | SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioNull> | SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioPipe> | SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe> | SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioNull> | SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioNull> | SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioPipe> | SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioNull> | SpawnOptions) & {
@@ -1 +1 @@
1
- {"version":3,"file":"spawn.js","sources":["../../src/spawn.ts"],"sourcesContent":["import {\n spawn,\n SpawnOptions,\n SpawnOptionsWithoutStdio,\n SpawnOptionsWithStdioTuple,\n SpawnSyncReturns,\n StdioNull,\n StdioPipe,\n execSync,\n} from 'node:child_process';\nimport * as os from 'node:os';\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 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 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 const stopProcess = (): void => {\n try {\n let pstreeOutput: string;\n let regex: RegExp;\n if (os.platform() === 'darwin') {\n pstreeOutput = execSync(`pstree ${proc.pid}`).toString();\n regex = /\\d+/;\n } else {\n pstreeOutput = execSync(`pstree -p ${proc.pid}`).toString();\n regex = /\\d+/g;\n }\n const procIds = pstreeOutput.split('\\n').flatMap((line) => (line.match(regex) ?? []).map(Number));\n const descendantProcIds: number[] = [];\n for (const pid of procIds) {\n if (pid > 0 && (pid === proc.pid || descendantProcIds.length > 0)) {\n descendantProcIds.push(pid);\n }\n }\n\n const killScript = `kill ${descendantProcIds.join(' ')}`;\n if (options?.verbose) {\n console.info(pstreeOutput);\n console.info(`$ ${killScript}`);\n }\n execSync(killScript);\n } catch {\n // do nothing.\n }\n };\n if (options?.killOnExit) {\n process.on('exit', 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","on","data","mergeOutAndError","stopProcess","pstreeOutput","regex","os","platform","execSync","pid","toString","procIds","split","flatMap","line","match","map","Number","descendantProcIds","length","push","killScript","join","verbose","console","info","killOnExit","process","error","removeListener","removeAllListeners","code","signal","undefined","Error","status"],"mappings":"mFA+BOA,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,GAEbH,EAAKE,QAAQE,GAAG,QAASC,IACvBH,GAAUG,CAAI,IAEhBL,EAAKG,QAAQC,GAAG,QAASC,IACnBT,GAASU,iBACXJ,GAAUG,EAEVF,GAAUE,CACZ,IAGF,MAAME,EAAcA,KAClB,IACE,IAAIC,EACAC,EACkB,WAAlBC,EAAGC,YACLH,EAAeI,EAAU,UAASZ,EAAKa,OAAOC,WAC9CL,EAAQ,QAERD,EAAeI,EAAU,aAAYZ,EAAKa,OAAOC,WACjDL,EAAQ,QAEV,MAAMM,EAAUP,EAAaQ,MAAM,MAAMC,SAASC,IAAUA,EAAKC,MAAMV,IAAU,IAAIW,IAAIC,UACnFC,EAA8B,GACpC,IAAK,MAAMT,KAAOE,EACZF,EAAM,IAAMA,IAAQb,EAAKa,KAAOS,EAAkBC,OAAS,IAC7DD,EAAkBE,KAAKX,GAI3B,MAAMY,EAAc,QAAOH,EAAkBI,KAAK,OAC9C9B,GAAS+B,UACXC,QAAQC,KAAKrB,GACboB,QAAQC,KAAM,KAAIJ,MAEpBb,EAASa,EACX,CAAE,MACA,GAGA7B,GAASkC,YACXC,QAAQ3B,GAAG,OAAQG,GAGrBP,EAAKI,GAAG,SAAU4B,IAChBD,QAAQE,eAAe,OAAQ1B,GAC/BP,EAAKkC,mBAAmB,SACxBnC,EAAOiC,EAAM,IAEfhC,EAAKI,GAAG,SAAS,CAAC+B,EAAqBC,KACrCL,QAAQE,eAAe,OAAQ1B,QACd8B,IAAbrC,EAAKa,IACPd,EAAO,IAAIuC,MAAM,wBAEjBxC,EAAQ,CACNe,IAAKb,EAAKa,IACVX,SACAC,SACAoC,OAAQJ,EACRC,UAEJ,GAEH,CAAC,MAAOJ,GACPjC,EAAOiC,EACT,IAEJ"}
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, execSync } from 'node:child_process';\nimport * as os from 'node:os';\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 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 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 const stopProcess = (): void => {\n try {\n let pstreeOutput: string;\n let regex: RegExp;\n if (os.platform() === 'darwin') {\n pstreeOutput = execSync(`pstree ${proc.pid}`).toString();\n regex = /\\d+/;\n } else {\n pstreeOutput = execSync(`pstree -p ${proc.pid}`).toString();\n regex = /\\d+/g;\n }\n const procIds = pstreeOutput.split('\\n').flatMap((line) => (line.match(regex) ?? []).map(Number));\n const descendantProcIds: number[] = [];\n for (const pid of procIds) {\n if (pid > 0 && (pid === proc.pid || descendantProcIds.length > 0)) {\n descendantProcIds.push(pid);\n }\n }\n\n const killScript = `kill ${descendantProcIds.join(' ')}`;\n if (options?.verbose) {\n console.info(pstreeOutput);\n console.info(`$ ${killScript}`);\n }\n execSync(killScript);\n } catch {\n // do nothing.\n }\n };\n if (options?.killOnExit) {\n process.on('exit', 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","on","data","mergeOutAndError","stopProcess","pstreeOutput","regex","os","platform","execSync","pid","toString","procIds","split","flatMap","line","match","map","Number","descendantProcIds","length","push","killScript","join","verbose","console","info","killOnExit","process","error","removeListener","removeAllListeners","code","signal","undefined","Error","status"],"mappings":"mFA8BOA,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,GAEbH,EAAKE,QAAQE,GAAG,QAASC,IACvBH,GAAUG,CAAI,IAEhBL,EAAKG,QAAQC,GAAG,QAASC,IACnBT,GAASU,iBACXJ,GAAUG,EAEVF,GAAUE,CACZ,IAGF,MAAME,EAAcA,KAClB,IACE,IAAIC,EACAC,EACkB,WAAlBC,EAAGC,YACLH,EAAeI,EAAU,UAASZ,EAAKa,OAAOC,WAC9CL,EAAQ,QAERD,EAAeI,EAAU,aAAYZ,EAAKa,OAAOC,WACjDL,EAAQ,QAEV,MAAMM,EAAUP,EAAaQ,MAAM,MAAMC,SAASC,IAAUA,EAAKC,MAAMV,IAAU,IAAIW,IAAIC,UACnFC,EAA8B,GACpC,IAAK,MAAMT,KAAOE,EACZF,EAAM,IAAMA,IAAQb,EAAKa,KAAOS,EAAkBC,OAAS,IAC7DD,EAAkBE,KAAKX,GAI3B,MAAMY,EAAc,QAAOH,EAAkBI,KAAK,OAC9C9B,GAAS+B,UACXC,QAAQC,KAAKrB,GACboB,QAAQC,KAAM,KAAIJ,MAEpBb,EAASa,EACX,CAAE,MACA,GAGA7B,GAASkC,YACXC,QAAQ3B,GAAG,OAAQG,GAGrBP,EAAKI,GAAG,SAAU4B,IAChBD,QAAQE,eAAe,OAAQ1B,GAC/BP,EAAKkC,mBAAmB,SACxBnC,EAAOiC,EAAM,IAEfhC,EAAKI,GAAG,SAAS,CAAC+B,EAAqBC,KACrCL,QAAQE,eAAe,OAAQ1B,QACd8B,IAAbrC,EAAKa,IACPd,EAAO,IAAIuC,MAAM,wBAEjBxC,EAAQ,CACNe,IAAKb,EAAKa,IACVX,SACAC,SACAoC,OAAQJ,EACRC,UAEJ,GAEH,CAAC,MAAOJ,GACPjC,EAAOiC,EACT,IAEJ"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willbooster/shared-lib-node",
3
- "version": "2.0.1",
3
+ "version": "2.0.3",
4
4
  "license": "Apache-2.0",
5
5
  "author": "WillBooster Inc.",
6
6
  "sideEffects": false,
@@ -36,27 +36,27 @@
36
36
  },
37
37
  "prettier": "@willbooster/prettier-config",
38
38
  "devDependencies": {
39
- "@types/eslint": "8.21.1",
39
+ "@types/eslint": "8.40.2",
40
40
  "@types/micromatch": "4.0.2",
41
- "@types/prettier": "2.7.2",
42
- "@typescript-eslint/eslint-plugin": "5.54.0",
43
- "@typescript-eslint/parser": "5.54.0",
44
- "@willbooster/eslint-config-ts": "10.0.8",
41
+ "@types/prettier": "2.7.3",
42
+ "@typescript-eslint/eslint-plugin": "5.59.11",
43
+ "@typescript-eslint/parser": "5.59.11",
44
+ "@willbooster/eslint-config-ts": "10.2.0",
45
45
  "@willbooster/prettier-config": "9.1.1",
46
- "build-ts": "5.7.4",
47
- "eslint": "8.35.0",
48
- "eslint-config-prettier": "8.6.0",
49
- "eslint-import-resolver-typescript": "3.5.3",
46
+ "build-ts": "5.10.3",
47
+ "eslint": "8.43.0",
48
+ "eslint-config-prettier": "8.8.0",
49
+ "eslint-import-resolver-typescript": "3.5.5",
50
50
  "eslint-plugin-import": "2.27.5",
51
- "eslint-plugin-sort-class-members": "1.16.0",
51
+ "eslint-plugin-sort-class-members": "1.18.0",
52
52
  "eslint-plugin-sort-destructure-keys": "1.5.0",
53
- "eslint-plugin-unicorn": "45.0.2",
54
- "lint-staged": "13.1.2",
53
+ "eslint-plugin-unicorn": "47.0.0",
54
+ "lint-staged": "13.2.2",
55
55
  "micromatch": "4.0.5",
56
- "prettier": "2.8.4",
56
+ "prettier": "2.8.8",
57
57
  "sort-package-json": "2.4.1",
58
- "typescript": "4.9.5",
59
- "vitest": "0.29.2"
58
+ "typescript": "5.1.3",
59
+ "vitest": "0.32.2"
60
60
  },
61
61
  "publishConfig": {
62
62
  "access": "public"