teen_process 2.1.6 → 2.1.7
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/build/lib/exec.d.ts +5 -5
- package/build/lib/exec.d.ts.map +1 -1
- package/build/lib/exec.js +17 -11
- package/build/lib/exec.js.map +1 -1
- package/build/lib/helpers.d.ts.map +1 -1
- package/build/lib/helpers.js +1 -2
- package/build/lib/helpers.js.map +1 -1
- package/build/lib/index.d.ts +0 -1
- package/build/lib/index.d.ts.map +1 -1
- package/build/lib/subprocess.d.ts +9 -12
- package/build/lib/subprocess.d.ts.map +1 -1
- package/build/lib/subprocess.js +28 -59
- package/build/lib/subprocess.js.map +1 -1
- package/lib/exec.js +16 -9
- package/lib/subprocess.js +29 -69
- package/package.json +2 -2
package/build/lib/exec.d.ts
CHANGED
|
@@ -37,7 +37,7 @@ export type TeenProcessLogger = {
|
|
|
37
37
|
/**
|
|
38
38
|
* Options for {@link exec teen_process.exec}.
|
|
39
39
|
*/
|
|
40
|
-
export type TeenProcessExecOptions = import(
|
|
40
|
+
export type TeenProcessExecOptions = import("child_process").SpawnOptions & TeenProcessProps;
|
|
41
41
|
/**
|
|
42
42
|
* The value {@link exec teen_process.exec} resolves to when `isBuffer` is `false`
|
|
43
43
|
*/
|
|
@@ -94,15 +94,15 @@ export type TeenProcessExecErrorProps = {
|
|
|
94
94
|
*/
|
|
95
95
|
export type TeenProcessExecError = Error & TeenProcessExecErrorProps;
|
|
96
96
|
export type BufferProp<MaybeBuffer extends {
|
|
97
|
-
isBuffer?: boolean
|
|
98
|
-
}> = MaybeBuffer[
|
|
97
|
+
isBuffer?: boolean;
|
|
98
|
+
}> = MaybeBuffer["isBuffer"];
|
|
99
99
|
/**
|
|
100
100
|
* Spawns a process
|
|
101
101
|
* @template {TeenProcessExecOptions} T
|
|
102
102
|
* @param {string} cmd - Program to execute
|
|
103
103
|
* @param {string[]} [args] - Arguments to pass to the program
|
|
104
|
-
* @param {T} [
|
|
104
|
+
* @param {T} [originalOpts] - Options
|
|
105
105
|
* @returns {Promise<BufferProp<T> extends true ? TeenProcessExecBufferResult : TeenProcessExecStringResult>}
|
|
106
106
|
*/
|
|
107
|
-
export function exec<T extends TeenProcessExecOptions>(cmd: string, args?: string[] | undefined,
|
|
107
|
+
export function exec<T extends TeenProcessExecOptions>(cmd: string, args?: string[] | undefined, originalOpts?: T | undefined): Promise<BufferProp<T> extends true ? TeenProcessExecBufferResult : TeenProcessExecStringResult>;
|
|
108
108
|
//# sourceMappingURL=exec.d.ts.map
|
package/build/lib/exec.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exec.d.ts","sourceRoot":"","sources":["../../lib/exec.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"exec.d.ts","sourceRoot":"","sources":["../../lib/exec.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WA8Kc,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI;;;;;qCAKzB,OAAO,eAAe,EAAE,YAAY,GAAG,gBAAgB;;;;;;;;YAMtD,MAAM;;;;YACN,MAAM;;;;UACN,MAAM,OAAC;;;;;;;;;YAMP,MAAM;;;;YACN,MAAM;;;;UACN,MAAM,OAAC;;;;;;;;;YAMP,MAAM;;;;YACN,MAAM;;;;UACN,MAAM,OAAC;;;;;mCAKR,KAAK,GAAG,yBAAyB;uBAIV,WAAW,SAAlC;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,IACtB,WAAW,CAAC,UAAU,CAAC;AA3MpC;;;;;;;GAOG;AACH,qBANsC,CAAC,SAAzB,sBAAuB,OAC1B,MAAM,8DAGJ,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,IAAI,GAAG,2BAA2B,GAAG,2BAA2B,CAAC,CA2I3G"}
|
package/build/lib/exec.js
CHANGED
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
5
|
};
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.exec =
|
|
7
|
+
exports.exec = exec;
|
|
8
8
|
const child_process_1 = require("child_process");
|
|
9
9
|
const shell_quote_1 = require("shell-quote");
|
|
10
10
|
const bluebird_1 = __importDefault(require("bluebird"));
|
|
@@ -16,15 +16,15 @@ const MAX_BUFFER_SIZE = 100 * 1024 * 1024;
|
|
|
16
16
|
* @template {TeenProcessExecOptions} T
|
|
17
17
|
* @param {string} cmd - Program to execute
|
|
18
18
|
* @param {string[]} [args] - Arguments to pass to the program
|
|
19
|
-
* @param {T} [
|
|
19
|
+
* @param {T} [originalOpts] - Options
|
|
20
20
|
* @returns {Promise<BufferProp<T> extends true ? TeenProcessExecBufferResult : TeenProcessExecStringResult>}
|
|
21
21
|
*/
|
|
22
|
-
async function exec(cmd, args = [],
|
|
22
|
+
async function exec(cmd, args = [], originalOpts = /** @type {T} */ ({})) {
|
|
23
23
|
// get a quoted representation of the command for error strings
|
|
24
24
|
const rep = (0, shell_quote_1.quote)([cmd, ...args]);
|
|
25
25
|
// extend default options; we're basically re-implementing exec's options
|
|
26
26
|
// for use here with spawn under the hood
|
|
27
|
-
opts = /** @type {T} */ (lodash_1.default.defaults(
|
|
27
|
+
const opts = /** @type {T} */ (lodash_1.default.defaults(originalOpts, {
|
|
28
28
|
timeout: null,
|
|
29
29
|
encoding: 'utf8',
|
|
30
30
|
killSignal: 'SIGTERM',
|
|
@@ -43,8 +43,12 @@ async function exec(cmd, args = [], opts = /** @type {T} */ ({})) {
|
|
|
43
43
|
return await new bluebird_1.default((resolve, reject) => {
|
|
44
44
|
// spawn the child process with options; we don't currently expose any of
|
|
45
45
|
// the other 'spawn' options through the API
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
const proc = (0, child_process_1.spawn)(cmd, args, { cwd: opts.cwd, env: opts.env, shell: opts.shell });
|
|
47
|
+
/** @type {Buffer[]} */
|
|
48
|
+
const stdoutArr = [];
|
|
49
|
+
/** @type {Buffer[]} */
|
|
50
|
+
const stderrArr = [];
|
|
51
|
+
let timer = null;
|
|
48
52
|
// if the process errors out, reject the promise
|
|
49
53
|
proc.on('error', /** @param {NodeJS.ErrnoException} err */ async (err) => {
|
|
50
54
|
if (err.code === 'ENOENT') {
|
|
@@ -72,7 +76,7 @@ async function exec(cmd, args = [], opts = /** @type {T} */ ({})) {
|
|
|
72
76
|
// keep track of the stream if we don't want to ignore it
|
|
73
77
|
const { chunks, maxSize } = streamProps;
|
|
74
78
|
let size = 0;
|
|
75
|
-
proc[streamType].on('data', (chunk) => {
|
|
79
|
+
proc[streamType].on('data', (/** @type {Buffer} */ chunk) => {
|
|
76
80
|
chunks.push(chunk);
|
|
77
81
|
size += chunk.length;
|
|
78
82
|
while (chunks.length > 1 && size >= maxSize) {
|
|
@@ -98,7 +102,10 @@ async function exec(cmd, args = [], opts = /** @type {T} */ ({})) {
|
|
|
98
102
|
* @returns {U extends true ? {stdout: Buffer, stderr: Buffer} : {stdout: string, stderr: string}}
|
|
99
103
|
*/
|
|
100
104
|
function getStdio(isBuffer) {
|
|
101
|
-
|
|
105
|
+
/** @type {string | Buffer} */
|
|
106
|
+
let stdout;
|
|
107
|
+
/** @type {string | Buffer} */
|
|
108
|
+
let stderr;
|
|
102
109
|
if (isBuffer) {
|
|
103
110
|
stdout = Buffer.concat(stdoutArr);
|
|
104
111
|
stderr = Buffer.concat(stderrArr);
|
|
@@ -116,7 +123,7 @@ async function exec(cmd, args = [], opts = /** @type {T} */ ({})) {
|
|
|
116
123
|
if (timer) {
|
|
117
124
|
clearTimeout(timer);
|
|
118
125
|
}
|
|
119
|
-
|
|
126
|
+
const { stdout, stderr } = getStdio(isBuffer);
|
|
120
127
|
if (code === 0) {
|
|
121
128
|
resolve(/** @type {BufferProp<T> extends true ? TeenProcessExecBufferResult : TeenProcessExecStringResult} */ ({ stdout, stderr, code }));
|
|
122
129
|
}
|
|
@@ -131,7 +138,7 @@ async function exec(cmd, args = [], opts = /** @type {T} */ ({})) {
|
|
|
131
138
|
// have in case it's helpful in debugging
|
|
132
139
|
if (opts.timeout) {
|
|
133
140
|
timer = setTimeout(() => {
|
|
134
|
-
|
|
141
|
+
const { stdout, stderr } = getStdio(isBuffer);
|
|
135
142
|
let err = new Error(`Command '${rep}' timed out after ${opts.timeout}ms`);
|
|
136
143
|
err = Object.assign(err, { stdout, stderr, code: null });
|
|
137
144
|
reject(err);
|
|
@@ -142,7 +149,6 @@ async function exec(cmd, args = [], opts = /** @type {T} */ ({})) {
|
|
|
142
149
|
}
|
|
143
150
|
});
|
|
144
151
|
}
|
|
145
|
-
exports.exec = exec;
|
|
146
152
|
exports.default = exec;
|
|
147
153
|
/**
|
|
148
154
|
* Options on top of `SpawnOptions`, unique to `teen_process.`
|
package/build/lib/exec.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exec.js","sourceRoot":"","sources":["../../lib/exec.js"],"names":[],"mappings":";AAAA,sDAAsD
|
|
1
|
+
{"version":3,"file":"exec.js","sourceRoot":"","sources":["../../lib/exec.js"],"names":[],"mappings":";AAAA,sDAAsD;;;;;AA6J7C,oBAAI;AA3Jb,iDAAsC;AACtC,6CAAoC;AACpC,wDAAyB;AACzB,oDAAuB;AACvB,uCAAyC;AAEzC,MAAM,eAAe,GAAG,GAAG,GAAG,IAAI,GAAG,IAAI,CAAC;AAE1C;;;;;;;GAOG;AACH,KAAK,UAAU,IAAI,CAAE,GAAG,EAAE,IAAI,GAAG,EAAE,EAAE,YAAY,GAAG,gBAAgB,CAAA,CAAC,EAAE,CAAC;IACtE,+DAA+D;IAC/D,MAAM,GAAG,GAAG,IAAA,mBAAK,EAAC,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC;IAElC,yEAAyE;IACzE,yCAAyC;IACzC,MAAM,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IAAI,CAAC,UAAU,CAAC,CAAC;YAC7B,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QACnB,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAGD,kBAAe,IAAI,CAAC;AAEpB;;;;;;;;;GASG;AAEH;;;;GAIG;AAEH;;;GAGG;AAEH;;;;;;GAMG;AAEH;;;;;;GAMG;AAEH;;;;;;GAMG;AAEH;;;GAGG;AAEH;;;;GAIG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../lib/helpers.js"],"names":[],"mappings":"AAGA;;;;;;;;;;GAUG;AACH,oCAPW,
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../lib/helpers.js"],"names":[],"mappings":"AAGA;;;;;;;;;;GAUG;AACH,oCAPW,MAAM,CAAC,cAAc,OAErB,MAAM,oCAEJ,OAAO,CAAC,MAAM,CAAC,cAAc,CAAC,CAwB1C"}
|
package/build/lib/helpers.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.formatEnoent =
|
|
6
|
+
exports.formatEnoent = formatEnoent;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const promises_1 = __importDefault(require("fs/promises"));
|
|
9
9
|
/**
|
|
@@ -39,5 +39,4 @@ async function formatEnoent(error, cmd, cwd = null) {
|
|
|
39
39
|
`nor in any folders specified in the PATH environment variable (${pathMsg})`;
|
|
40
40
|
return error;
|
|
41
41
|
}
|
|
42
|
-
exports.formatEnoent = formatEnoent;
|
|
43
42
|
//# sourceMappingURL=helpers.js.map
|
package/build/lib/helpers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../lib/helpers.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../lib/helpers.js"],"names":[],"mappings":";;;;;AAqCS,oCAAY;AArCrB,gDAAwB;AACxB,2DAA6B;AAE7B;;;;;;;;;;GAUG;AACH,KAAK,UAAU,YAAY,CAAE,KAAK,EAAE,GAAG,EAAE,GAAG,GAAG,IAAI;IACjD,IAAI,GAAG,EAAE,CAAC;QACR,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,MAAM,kBAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YAChC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;gBACxB,KAAK,CAAC,OAAO,GAAG,0BAA0B,GAAG,SAAS,GAAG,8BAA8B,CAAC;gBACxF,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,IAAI,CAAC,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;gBACxB,KAAK,CAAC,OAAO,GAAG,0BAA0B,GAAG,SAAS,GAAG,kBAAkB,CAAC;gBAC5E,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC;IACH,CAAC;IAED,MAAM,MAAM,GAAG,cAAI,CAAC,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IAClD,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,sCAAsC,CAAC;IAC3E,KAAK,CAAC,OAAO,GAAG,IAAI,GAAG,oEAAoE,MAAM,IAAI;QACnG,kEAAkE,OAAO,GAAG,CAAC;IAC/E,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/build/lib/index.d.ts
CHANGED
package/build/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/index.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/index.js"],"names":[],"mappings":";;;2BAK2B,QAAQ;oBAFf,eAAe;yBACV,cAAc"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
export default SubProcess;
|
|
3
2
|
export type StartDetector = (stdout: string, stderr?: string | undefined) => any;
|
|
4
3
|
export class SubProcess extends events<[never]> {
|
|
@@ -8,15 +7,8 @@ export class SubProcess extends events<[never]> {
|
|
|
8
7
|
* @param {any} [opts]
|
|
9
8
|
*/
|
|
10
9
|
constructor(cmd: string, args?: string[] | undefined, opts?: any);
|
|
11
|
-
/**
|
|
12
|
-
* @type { {stdout: string, stderr: string} }
|
|
13
|
-
*/
|
|
14
|
-
lastLinePortion: {
|
|
15
|
-
stdout: string;
|
|
16
|
-
stderr: string;
|
|
17
|
-
};
|
|
18
10
|
/** @type {import('child_process').ChildProcess?} */
|
|
19
|
-
proc: import(
|
|
11
|
+
proc: import("child_process").ChildProcess | null;
|
|
20
12
|
/** @type {string[]} */
|
|
21
13
|
args: string[];
|
|
22
14
|
/**
|
|
@@ -38,11 +30,13 @@ export class SubProcess extends events<[never]> {
|
|
|
38
30
|
get isRunning(): boolean;
|
|
39
31
|
/**
|
|
40
32
|
*
|
|
41
|
-
* @param {string}
|
|
42
|
-
* @param {Iterable<string
|
|
33
|
+
* @param {string} streamName
|
|
34
|
+
* @param {Iterable<string>|string} lines
|
|
43
35
|
*/
|
|
44
|
-
emitLines(
|
|
36
|
+
emitLines(streamName: string, lines: Iterable<string> | string): void;
|
|
45
37
|
/**
|
|
38
|
+
* spawn the subprocess and return control whenever we deem that it has fully
|
|
39
|
+
* "started"
|
|
46
40
|
*
|
|
47
41
|
* @param {StartDetector|number?} startDetector
|
|
48
42
|
* @param {number?} timeoutMs
|
|
@@ -50,6 +44,9 @@ export class SubProcess extends events<[never]> {
|
|
|
50
44
|
* @returns {Promise<void>}
|
|
51
45
|
*/
|
|
52
46
|
start(startDetector?: StartDetector | (number | null), timeoutMs?: number | null, detach?: boolean): Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* @deprecated This method is deprecated and will be removed
|
|
49
|
+
*/
|
|
53
50
|
handleLastLines(): void;
|
|
54
51
|
/**
|
|
55
52
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subprocess.d.ts","sourceRoot":"","sources":["../../lib/subprocess.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"subprocess.d.ts","sourceRoot":"","sources":["../../lib/subprocess.js"],"names":[],"mappings":";qCA8SW,MAAM,kCAEJ,GAAG;AAvShB;IA4BE;;;;OAIG;IACH,iBAJW,MAAM,sCAEN,GAAG,EAgBb;IA7CD,oDAAoD;IACpD,MADW,OAAO,eAAe,EAAE,YAAY,OAAC,CAC3C;IAEL,uBAAuB;IACvB,MADW,MAAM,EAAE,CACd;IAEL;;OAEG;IACH,KAFU,MAAM,CAEZ;IAEJ;;MAEE;IACF,MAFU,GAAG,CAER;IAEL;;OAEG;IACH,eAFU,OAAO,CAEH;IAEd;;OAEG;IACH,KAFU,MAAM,CAEZ;IAuBJ,yBAGC;IAED;;;;OAIG;IACH,sBAHW,MAAM,SACN,QAAQ,CAAC,MAAM,CAAC,GAAC,MAAM,QAYjC;IAED;;;;;;;;OAQG;IACH,sBALW,aAAa,IAAC,MAAM,OAAC,CAAA,cACrB,MAAM,OAAC,WACP,OAAO,GACL,OAAO,CAAC,IAAI,CAAC,CAgJzB;IAED;;OAEG;IACH,wBAGC;IAED;;;;;OAKG;IACH,cAJW,MAAM,CAAC,OAAO,YACd,MAAM,GACJ,OAAO,CAAC,IAAI,CAAC,CAgBzB;IAED,gDAcC;IAKD,sBAQC;IAED,qCAEC;CACF;mBAtSkB,QAAQ"}
|
package/build/lib/subprocess.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/* eslint-disable promise/prefer-await-to-callbacks */
|
|
3
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
4
|
};
|
|
@@ -12,16 +11,7 @@ const bluebird_1 = __importDefault(require("bluebird"));
|
|
|
12
11
|
const shell_quote_1 = require("shell-quote");
|
|
13
12
|
const lodash_1 = __importDefault(require("lodash"));
|
|
14
13
|
const helpers_1 = require("./helpers");
|
|
15
|
-
|
|
16
|
-
// when the process output is too long and contains
|
|
17
|
-
// no line breaks
|
|
18
|
-
const MAX_LINE_PORTION_LENGTH = 0xFFFF;
|
|
19
|
-
function cutSuffix(str, suffixLength) {
|
|
20
|
-
return str.length > suffixLength
|
|
21
|
-
// https://bugs.chromium.org/p/v8/issues/detail?id=2869
|
|
22
|
-
? ` ${str.substr(str.length - suffixLength)}`.substr(1)
|
|
23
|
-
: str;
|
|
24
|
-
}
|
|
14
|
+
const node_readline_1 = require("node:readline");
|
|
25
15
|
class SubProcess extends EventEmitter {
|
|
26
16
|
/**
|
|
27
17
|
* @param {string} cmd
|
|
@@ -43,7 +33,6 @@ class SubProcess extends EventEmitter {
|
|
|
43
33
|
this.expectingExit = false;
|
|
44
34
|
// get a quoted representation of the command for error strings
|
|
45
35
|
this.rep = (0, shell_quote_1.quote)([cmd, ...args]);
|
|
46
|
-
this.lastLinePortion = { stdout: '', stderr: '' };
|
|
47
36
|
}
|
|
48
37
|
get isRunning() {
|
|
49
38
|
// presence of `proc` means we have connected and started
|
|
@@ -51,17 +40,23 @@ class SubProcess extends EventEmitter {
|
|
|
51
40
|
}
|
|
52
41
|
/**
|
|
53
42
|
*
|
|
54
|
-
* @param {string}
|
|
55
|
-
* @param {Iterable<string
|
|
43
|
+
* @param {string} streamName
|
|
44
|
+
* @param {Iterable<string>|string} lines
|
|
56
45
|
*/
|
|
57
|
-
emitLines(
|
|
58
|
-
|
|
59
|
-
|
|
46
|
+
emitLines(streamName, lines) {
|
|
47
|
+
const doEmit = (/** @type {string} */ line) => this.emit('stream-line', `[${streamName.toUpperCase()}] ${line}`);
|
|
48
|
+
if (lodash_1.default.isString(lines)) {
|
|
49
|
+
doEmit(lines);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
for (const line of lines) {
|
|
53
|
+
doEmit(line);
|
|
54
|
+
}
|
|
60
55
|
}
|
|
61
56
|
}
|
|
62
|
-
// spawn the subprocess and return control whenever we deem that it has fully
|
|
63
|
-
// "started"
|
|
64
57
|
/**
|
|
58
|
+
* spawn the subprocess and return control whenever we deem that it has fully
|
|
59
|
+
* "started"
|
|
65
60
|
*
|
|
66
61
|
* @param {StartDetector|number?} startDetector
|
|
67
62
|
* @param {number?} timeoutMs
|
|
@@ -108,7 +103,6 @@ class SubProcess extends EventEmitter {
|
|
|
108
103
|
if (this.proc.stderr) {
|
|
109
104
|
this.proc.stderr.setEncoding(this.opts.encoding || 'utf8');
|
|
110
105
|
}
|
|
111
|
-
this.lastLinePortion = { stdout: '', stderr: '' };
|
|
112
106
|
// this function handles output that we collect from the subproc
|
|
113
107
|
/**
|
|
114
108
|
*
|
|
@@ -129,33 +123,6 @@ class SubProcess extends EventEmitter {
|
|
|
129
123
|
}
|
|
130
124
|
// emit the actual output for whomever's listening
|
|
131
125
|
this.emit('output', stdout, stderr);
|
|
132
|
-
// we also want to emit lines, but it's more complex since output
|
|
133
|
-
// comes in chunks and a line could come in two different chunks, so
|
|
134
|
-
// we have logic to handle that case (using this.lastLinePortion to
|
|
135
|
-
// remember a line that started but did not finish in the last chunk)
|
|
136
|
-
for (const [streamName, streamData] of /** @type {[['stdout', string], ['stderr', string]]} */ (lodash_1.default.toPairs(streams))) {
|
|
137
|
-
if (!streamData)
|
|
138
|
-
continue; // eslint-disable-line curly
|
|
139
|
-
const lines = streamData.split('\n')
|
|
140
|
-
// https://bugs.chromium.org/p/v8/issues/detail?id=2869
|
|
141
|
-
.map((x) => ` ${x}`.substr(1));
|
|
142
|
-
if (lines.length > 1) {
|
|
143
|
-
lines[0] = this.lastLinePortion[streamName] + lines[0];
|
|
144
|
-
this.lastLinePortion[streamName] = cutSuffix(lodash_1.default.last(lines), MAX_LINE_PORTION_LENGTH);
|
|
145
|
-
const resultLines = lines.slice(0, -1);
|
|
146
|
-
this.emit(`lines-${streamName}`, resultLines);
|
|
147
|
-
this.emitLines(streamName, resultLines);
|
|
148
|
-
}
|
|
149
|
-
else {
|
|
150
|
-
const currentPortion = cutSuffix(lines[0], MAX_LINE_PORTION_LENGTH);
|
|
151
|
-
if (this.lastLinePortion[streamName].length + currentPortion.length > MAX_LINE_PORTION_LENGTH) {
|
|
152
|
-
this.lastLinePortion[streamName] = currentPortion;
|
|
153
|
-
}
|
|
154
|
-
else {
|
|
155
|
-
this.lastLinePortion[streamName] += currentPortion;
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
126
|
};
|
|
160
127
|
// if we get an error spawning the proc, reject and clean up the proc
|
|
161
128
|
this.proc.on('error', /** @param {NodeJS.ErrnoException} err */ async (err) => {
|
|
@@ -168,17 +135,25 @@ class SubProcess extends EventEmitter {
|
|
|
168
135
|
this.proc?.unref();
|
|
169
136
|
this.proc = null;
|
|
170
137
|
});
|
|
138
|
+
const handleStreamLines = (/** @type {string} */ streamName, /** @type {import('stream').Readable} */ input) => {
|
|
139
|
+
const rl = (0, node_readline_1.createInterface)({ input });
|
|
140
|
+
rl.on('line', (line) => {
|
|
141
|
+
this.emit(`lines-${streamName}`, [line]);
|
|
142
|
+
this.emitLines(streamName, line);
|
|
143
|
+
});
|
|
144
|
+
};
|
|
171
145
|
if (this.proc.stdout) {
|
|
172
146
|
this.proc.stdout.on('data', (chunk) => handleOutput({ stdout: chunk.toString(), stderr: '' }));
|
|
147
|
+
handleStreamLines('stdout', this.proc.stdout);
|
|
173
148
|
}
|
|
174
149
|
if (this.proc.stderr) {
|
|
175
150
|
this.proc.stderr.on('data', (chunk) => handleOutput({ stdout: '', stderr: chunk.toString() }));
|
|
151
|
+
handleStreamLines('stderr', this.proc.stderr);
|
|
176
152
|
}
|
|
177
153
|
// when the proc exits, we might still have a buffer of lines we were
|
|
178
154
|
// waiting on more chunks to complete. Go ahead and emit those, then
|
|
179
155
|
// re-emit the exit so a listener can handle the possibly-unexpected exit
|
|
180
156
|
this.proc.on('exit', (code, signal) => {
|
|
181
|
-
this.handleLastLines();
|
|
182
157
|
this.emit('exit', code, signal);
|
|
183
158
|
// in addition to the bare exit event, also emit one of three other
|
|
184
159
|
// events that contain more helpful information:
|
|
@@ -214,15 +189,12 @@ class SubProcess extends EventEmitter {
|
|
|
214
189
|
}
|
|
215
190
|
});
|
|
216
191
|
}
|
|
192
|
+
/**
|
|
193
|
+
* @deprecated This method is deprecated and will be removed
|
|
194
|
+
*/
|
|
217
195
|
handleLastLines() {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
const lastLines = [this.lastLinePortion[stream]];
|
|
221
|
-
this.emit(`lines-${stream}`, lastLines);
|
|
222
|
-
this.emitLines(stream, lastLines);
|
|
223
|
-
this.lastLinePortion[stream] = '';
|
|
224
|
-
}
|
|
225
|
-
}
|
|
196
|
+
// TODO: THis is a noop left for backward compatibility.
|
|
197
|
+
// TODO: Remove it after the major version bump
|
|
226
198
|
}
|
|
227
199
|
/**
|
|
228
200
|
*
|
|
@@ -234,9 +206,6 @@ class SubProcess extends EventEmitter {
|
|
|
234
206
|
if (!this.isRunning) {
|
|
235
207
|
throw new Error(`Can't stop process; it's not currently running (cmd: '${this.rep}')`);
|
|
236
208
|
}
|
|
237
|
-
// make sure to emit any data in our lines buffer whenever we're done with
|
|
238
|
-
// the proc
|
|
239
|
-
this.handleLastLines();
|
|
240
209
|
return await new bluebird_1.default((resolve, reject) => {
|
|
241
210
|
this.proc?.on('close', resolve);
|
|
242
211
|
this.expectingExit = true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subprocess.js","sourceRoot":"","sources":["../../lib/subprocess.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"subprocess.js","sourceRoot":"","s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ED,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;IAC1C,CAAC;CACF;AAEQ,gCAAU;AACnB,kBAAe,UAAU,CAAC;AAE1B;;;;;GAKG"}
|
package/lib/exec.js
CHANGED
|
@@ -13,16 +13,16 @@ const MAX_BUFFER_SIZE = 100 * 1024 * 1024;
|
|
|
13
13
|
* @template {TeenProcessExecOptions} T
|
|
14
14
|
* @param {string} cmd - Program to execute
|
|
15
15
|
* @param {string[]} [args] - Arguments to pass to the program
|
|
16
|
-
* @param {T} [
|
|
16
|
+
* @param {T} [originalOpts] - Options
|
|
17
17
|
* @returns {Promise<BufferProp<T> extends true ? TeenProcessExecBufferResult : TeenProcessExecStringResult>}
|
|
18
18
|
*/
|
|
19
|
-
async function exec (cmd, args = [],
|
|
19
|
+
async function exec (cmd, args = [], originalOpts = /** @type {T} */({})) {
|
|
20
20
|
// get a quoted representation of the command for error strings
|
|
21
21
|
const rep = quote([cmd, ...args]);
|
|
22
22
|
|
|
23
23
|
// extend default options; we're basically re-implementing exec's options
|
|
24
24
|
// for use here with spawn under the hood
|
|
25
|
-
opts = /** @type {T} */(_.defaults(
|
|
25
|
+
const opts = /** @type {T} */(_.defaults(originalOpts, {
|
|
26
26
|
timeout: null,
|
|
27
27
|
encoding: 'utf8',
|
|
28
28
|
killSignal: 'SIGTERM',
|
|
@@ -43,8 +43,12 @@ async function exec (cmd, args = [], opts = /** @type {T} */({})) {
|
|
|
43
43
|
return await new B((resolve, reject) => {
|
|
44
44
|
// spawn the child process with options; we don't currently expose any of
|
|
45
45
|
// the other 'spawn' options through the API
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
const proc = spawn(cmd, args, {cwd: opts.cwd, env: opts.env, shell: opts.shell});
|
|
47
|
+
/** @type {Buffer[]} */
|
|
48
|
+
const stdoutArr = [];
|
|
49
|
+
/** @type {Buffer[]} */
|
|
50
|
+
const stderrArr = [];
|
|
51
|
+
let timer = null;
|
|
48
52
|
|
|
49
53
|
// if the process errors out, reject the promise
|
|
50
54
|
proc.on('error', /** @param {NodeJS.ErrnoException} err */ async (err) => {
|
|
@@ -76,7 +80,7 @@ async function exec (cmd, args = [], opts = /** @type {T} */({})) {
|
|
|
76
80
|
// keep track of the stream if we don't want to ignore it
|
|
77
81
|
const {chunks, maxSize} = streamProps;
|
|
78
82
|
let size = 0;
|
|
79
|
-
proc[streamType].on('data', (chunk) => {
|
|
83
|
+
proc[streamType].on('data', (/** @type {Buffer} */ chunk) => {
|
|
80
84
|
chunks.push(chunk);
|
|
81
85
|
size += chunk.length;
|
|
82
86
|
while (chunks.length > 1 && size >= maxSize) {
|
|
@@ -103,7 +107,10 @@ async function exec (cmd, args = [], opts = /** @type {T} */({})) {
|
|
|
103
107
|
* @returns {U extends true ? {stdout: Buffer, stderr: Buffer} : {stdout: string, stderr: string}}
|
|
104
108
|
*/
|
|
105
109
|
function getStdio (isBuffer) {
|
|
106
|
-
|
|
110
|
+
/** @type {string | Buffer} */
|
|
111
|
+
let stdout;
|
|
112
|
+
/** @type {string | Buffer} */
|
|
113
|
+
let stderr;
|
|
107
114
|
if (isBuffer) {
|
|
108
115
|
stdout = Buffer.concat(stdoutArr);
|
|
109
116
|
stderr = Buffer.concat(stderrArr);
|
|
@@ -121,7 +128,7 @@ async function exec (cmd, args = [], opts = /** @type {T} */({})) {
|
|
|
121
128
|
if (timer) {
|
|
122
129
|
clearTimeout(timer);
|
|
123
130
|
}
|
|
124
|
-
|
|
131
|
+
const {stdout, stderr} = getStdio(isBuffer);
|
|
125
132
|
if (code === 0) {
|
|
126
133
|
resolve(/** @type {BufferProp<T> extends true ? TeenProcessExecBufferResult : TeenProcessExecStringResult} */({stdout, stderr, code}));
|
|
127
134
|
} else {
|
|
@@ -136,7 +143,7 @@ async function exec (cmd, args = [], opts = /** @type {T} */({})) {
|
|
|
136
143
|
// have in case it's helpful in debugging
|
|
137
144
|
if (opts.timeout) {
|
|
138
145
|
timer = setTimeout(() => {
|
|
139
|
-
|
|
146
|
+
const {stdout, stderr} = getStdio(isBuffer);
|
|
140
147
|
let err = new Error(`Command '${rep}' timed out after ${opts.timeout}ms`);
|
|
141
148
|
err = Object.assign(err, {stdout, stderr, code: null});
|
|
142
149
|
reject(err);
|
package/lib/subprocess.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/* eslint-disable promise/prefer-await-to-callbacks */
|
|
2
|
-
|
|
3
1
|
import { spawn } from 'child_process';
|
|
4
2
|
import events from 'events';
|
|
5
3
|
const { EventEmitter } = events;
|
|
@@ -7,28 +5,10 @@ import B from 'bluebird';
|
|
|
7
5
|
import { quote } from 'shell-quote';
|
|
8
6
|
import _ from 'lodash';
|
|
9
7
|
import { formatEnoent } from './helpers';
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
// This is needed to avoid memory leaks
|
|
13
|
-
// when the process output is too long and contains
|
|
14
|
-
// no line breaks
|
|
15
|
-
const MAX_LINE_PORTION_LENGTH = 0xFFFF;
|
|
16
|
-
|
|
17
|
-
function cutSuffix (str, suffixLength) {
|
|
18
|
-
return str.length > suffixLength
|
|
19
|
-
// https://bugs.chromium.org/p/v8/issues/detail?id=2869
|
|
20
|
-
? ` ${str.substr(str.length - suffixLength)}`.substr(1)
|
|
21
|
-
: str;
|
|
22
|
-
}
|
|
23
|
-
|
|
8
|
+
import { createInterface } from 'node:readline';
|
|
24
9
|
|
|
25
10
|
class SubProcess extends EventEmitter {
|
|
26
11
|
|
|
27
|
-
/**
|
|
28
|
-
* @type { {stdout: string, stderr: string} }
|
|
29
|
-
*/
|
|
30
|
-
lastLinePortion;
|
|
31
|
-
|
|
32
12
|
/** @type {import('child_process').ChildProcess?} */
|
|
33
13
|
proc;
|
|
34
14
|
|
|
@@ -74,8 +54,6 @@ class SubProcess extends EventEmitter {
|
|
|
74
54
|
|
|
75
55
|
// get a quoted representation of the command for error strings
|
|
76
56
|
this.rep = quote([cmd, ...args]);
|
|
77
|
-
|
|
78
|
-
this.lastLinePortion = {stdout: '', stderr: ''};
|
|
79
57
|
}
|
|
80
58
|
|
|
81
59
|
get isRunning () {
|
|
@@ -85,18 +63,24 @@ class SubProcess extends EventEmitter {
|
|
|
85
63
|
|
|
86
64
|
/**
|
|
87
65
|
*
|
|
88
|
-
* @param {string}
|
|
89
|
-
* @param {Iterable<string
|
|
66
|
+
* @param {string} streamName
|
|
67
|
+
* @param {Iterable<string>|string} lines
|
|
90
68
|
*/
|
|
91
|
-
emitLines (
|
|
92
|
-
|
|
93
|
-
|
|
69
|
+
emitLines (streamName, lines) {
|
|
70
|
+
const doEmit = (/** @type {string} */ line) => this.emit('stream-line', `[${streamName.toUpperCase()}] ${line}`);
|
|
71
|
+
|
|
72
|
+
if (_.isString(lines)) {
|
|
73
|
+
doEmit(lines);
|
|
74
|
+
} else {
|
|
75
|
+
for (const line of lines) {
|
|
76
|
+
doEmit(line);
|
|
77
|
+
}
|
|
94
78
|
}
|
|
95
79
|
}
|
|
96
80
|
|
|
97
|
-
// spawn the subprocess and return control whenever we deem that it has fully
|
|
98
|
-
// "started"
|
|
99
81
|
/**
|
|
82
|
+
* spawn the subprocess and return control whenever we deem that it has fully
|
|
83
|
+
* "started"
|
|
100
84
|
*
|
|
101
85
|
* @param {StartDetector|number?} startDetector
|
|
102
86
|
* @param {number?} timeoutMs
|
|
@@ -148,7 +132,6 @@ class SubProcess extends EventEmitter {
|
|
|
148
132
|
if (this.proc.stderr) {
|
|
149
133
|
this.proc.stderr.setEncoding(this.opts.encoding || 'utf8');
|
|
150
134
|
}
|
|
151
|
-
this.lastLinePortion = {stdout: '', stderr: ''};
|
|
152
135
|
|
|
153
136
|
// this function handles output that we collect from the subproc
|
|
154
137
|
/**
|
|
@@ -170,31 +153,6 @@ class SubProcess extends EventEmitter {
|
|
|
170
153
|
|
|
171
154
|
// emit the actual output for whomever's listening
|
|
172
155
|
this.emit('output', stdout, stderr);
|
|
173
|
-
|
|
174
|
-
// we also want to emit lines, but it's more complex since output
|
|
175
|
-
// comes in chunks and a line could come in two different chunks, so
|
|
176
|
-
// we have logic to handle that case (using this.lastLinePortion to
|
|
177
|
-
// remember a line that started but did not finish in the last chunk)
|
|
178
|
-
for (const [streamName, streamData] of /** @type {[['stdout', string], ['stderr', string]]} */(_.toPairs(streams))) {
|
|
179
|
-
if (!streamData) continue; // eslint-disable-line curly
|
|
180
|
-
const lines = streamData.split('\n')
|
|
181
|
-
// https://bugs.chromium.org/p/v8/issues/detail?id=2869
|
|
182
|
-
.map((x) => ` ${x}`.substr(1));
|
|
183
|
-
if (lines.length > 1) {
|
|
184
|
-
lines[0] = this.lastLinePortion[streamName] + lines[0];
|
|
185
|
-
this.lastLinePortion[streamName] = cutSuffix(_.last(lines), MAX_LINE_PORTION_LENGTH);
|
|
186
|
-
const resultLines = lines.slice(0, -1);
|
|
187
|
-
this.emit(`lines-${streamName}`, resultLines);
|
|
188
|
-
this.emitLines(streamName, resultLines);
|
|
189
|
-
} else {
|
|
190
|
-
const currentPortion = cutSuffix(lines[0], MAX_LINE_PORTION_LENGTH);
|
|
191
|
-
if (this.lastLinePortion[streamName].length + currentPortion.length > MAX_LINE_PORTION_LENGTH) {
|
|
192
|
-
this.lastLinePortion[streamName] = currentPortion;
|
|
193
|
-
} else {
|
|
194
|
-
this.lastLinePortion[streamName] += currentPortion;
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
156
|
};
|
|
199
157
|
|
|
200
158
|
// if we get an error spawning the proc, reject and clean up the proc
|
|
@@ -211,20 +169,28 @@ class SubProcess extends EventEmitter {
|
|
|
211
169
|
this.proc = null;
|
|
212
170
|
});
|
|
213
171
|
|
|
172
|
+
const handleStreamLines = (/** @type {string} */ streamName, /** @type {import('stream').Readable} */ input) => {
|
|
173
|
+
const rl = createInterface({input});
|
|
174
|
+
rl.on('line', (line) => {
|
|
175
|
+
this.emit(`lines-${streamName}`, [line]);
|
|
176
|
+
this.emitLines(streamName, line);
|
|
177
|
+
});
|
|
178
|
+
};
|
|
179
|
+
|
|
214
180
|
if (this.proc.stdout) {
|
|
215
181
|
this.proc.stdout.on('data', (chunk) => handleOutput({stdout: chunk.toString(), stderr: ''}));
|
|
182
|
+
handleStreamLines('stdout', this.proc.stdout);
|
|
216
183
|
}
|
|
217
184
|
|
|
218
185
|
if (this.proc.stderr) {
|
|
219
186
|
this.proc.stderr.on('data', (chunk) => handleOutput({stdout: '', stderr: chunk.toString()}));
|
|
187
|
+
handleStreamLines('stderr', this.proc.stderr);
|
|
220
188
|
}
|
|
221
189
|
|
|
222
190
|
// when the proc exits, we might still have a buffer of lines we were
|
|
223
191
|
// waiting on more chunks to complete. Go ahead and emit those, then
|
|
224
192
|
// re-emit the exit so a listener can handle the possibly-unexpected exit
|
|
225
193
|
this.proc.on('exit', (code, signal) => {
|
|
226
|
-
this.handleLastLines();
|
|
227
|
-
|
|
228
194
|
this.emit('exit', code, signal);
|
|
229
195
|
|
|
230
196
|
// in addition to the bare exit event, also emit one of three other
|
|
@@ -265,15 +231,12 @@ class SubProcess extends EventEmitter {
|
|
|
265
231
|
});
|
|
266
232
|
}
|
|
267
233
|
|
|
234
|
+
/**
|
|
235
|
+
* @deprecated This method is deprecated and will be removed
|
|
236
|
+
*/
|
|
268
237
|
handleLastLines () {
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
const lastLines = [this.lastLinePortion[stream]];
|
|
272
|
-
this.emit(`lines-${stream}`, lastLines);
|
|
273
|
-
this.emitLines(stream, lastLines);
|
|
274
|
-
this.lastLinePortion[stream] = '';
|
|
275
|
-
}
|
|
276
|
-
}
|
|
238
|
+
// TODO: THis is a noop left for backward compatibility.
|
|
239
|
+
// TODO: Remove it after the major version bump
|
|
277
240
|
}
|
|
278
241
|
|
|
279
242
|
/**
|
|
@@ -286,9 +249,6 @@ class SubProcess extends EventEmitter {
|
|
|
286
249
|
if (!this.isRunning) {
|
|
287
250
|
throw new Error(`Can't stop process; it's not currently running (cmd: '${this.rep}')`);
|
|
288
251
|
}
|
|
289
|
-
// make sure to emit any data in our lines buffer whenever we're done with
|
|
290
|
-
// the proc
|
|
291
|
-
this.handleLastLines();
|
|
292
252
|
return await new B((resolve, reject) => {
|
|
293
253
|
this.proc?.on('close', resolve);
|
|
294
254
|
this.expectingExit = true;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "teen_process",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.7",
|
|
4
4
|
"description": "A grown up version of Node's spawn/exec",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"child_process",
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"prettier": "^3.1.0",
|
|
74
74
|
"semantic-release": "^24.0.0",
|
|
75
75
|
"sinon": "^18.0.0",
|
|
76
|
-
"typescript": "
|
|
76
|
+
"typescript": "^5.4.1",
|
|
77
77
|
"ts-node": "^10.9.1"
|
|
78
78
|
},
|
|
79
79
|
"engines": {
|