batch-cluster
Advanced tools
Comparing version 6.1.0 to 6.2.0
@@ -20,2 +20,6 @@ # Changelog | ||
## v6.2.0 | ||
- 📦 Updated development dependencies, which required handling undefined process ids. | ||
## v6.1.0 | ||
@@ -22,0 +26,0 @@ |
@@ -350,36 +350,41 @@ "use strict"; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var arr, _a, _b, pid, e_1_1; | ||
var e_1, _c; | ||
return __generator(this, function (_d) { | ||
switch (_d.label) { | ||
var arr, _a, _b, pid, _c, e_1_1; | ||
var e_1, _d; | ||
return __generator(this, function (_e) { | ||
switch (_e.label) { | ||
case 0: | ||
arr = []; | ||
_d.label = 1; | ||
_e.label = 1; | ||
case 1: | ||
_d.trys.push([1, 6, 7, 8]); | ||
_e.trys.push([1, 7, 8, 9]); | ||
_a = __values(this._procs.map(function (p) { return p.pid; })), _b = _a.next(); | ||
_d.label = 2; | ||
_e.label = 2; | ||
case 2: | ||
if (!!_b.done) return [3 /*break*/, 5]; | ||
if (!!_b.done) return [3 /*break*/, 6]; | ||
pid = _b.value; | ||
_c = pid != null; | ||
if (!_c) return [3 /*break*/, 4]; | ||
return [4 /*yield*/, Pids_1.pidExists(pid)]; | ||
case 3: | ||
if (_d.sent()) | ||
_c = (_e.sent()); | ||
_e.label = 4; | ||
case 4: | ||
if (_c) | ||
arr.push(pid); | ||
_d.label = 4; | ||
case 4: | ||
_e.label = 5; | ||
case 5: | ||
_b = _a.next(); | ||
return [3 /*break*/, 2]; | ||
case 5: return [3 /*break*/, 8]; | ||
case 6: | ||
e_1_1 = _d.sent(); | ||
case 6: return [3 /*break*/, 9]; | ||
case 7: | ||
e_1_1 = _e.sent(); | ||
e_1 = { error: e_1_1 }; | ||
return [3 /*break*/, 8]; | ||
case 7: | ||
return [3 /*break*/, 9]; | ||
case 8: | ||
try { | ||
if (_b && !_b.done && (_c = _a.return)) _c.call(_a); | ||
if (_b && !_b.done && (_d = _a.return)) _d.call(_a); | ||
} | ||
finally { if (e_1) throw e_1.error; } | ||
return [7 /*endfinally*/]; | ||
case 8: return [2 /*return*/, arr]; | ||
case 9: return [2 /*return*/, arr]; | ||
} | ||
@@ -386,0 +391,0 @@ }); |
@@ -36,3 +36,3 @@ /// <reference types="node" /> | ||
constructor(proc: _cp.ChildProcess, opts: InternalBatchProcessOptions, observer: BatchProcessObserver); | ||
get pid(): number; | ||
get pid(): number | undefined; | ||
get taskCount(): number; | ||
@@ -39,0 +39,0 @@ get exited(): boolean; |
@@ -331,3 +331,3 @@ "use strict"; | ||
case 9: | ||
if (!_d.sent()) return [3 /*break*/, 11]; | ||
if (!((_d.sent()) && this.proc.pid != null)) return [3 /*break*/, 11]; | ||
return [4 /*yield*/, Pids_1.kill(this.proc.pid) | ||
@@ -347,3 +347,4 @@ // Wait for the signal handler to work: | ||
case 13: | ||
_c = this.opts.cleanupChildProcs; | ||
_c = this.opts.cleanupChildProcs && | ||
this.proc.pid != null; | ||
if (!_c) return [3 /*break*/, 15]; | ||
@@ -350,0 +351,0 @@ return [4 /*yield*/, this.running()]; |
@@ -8,3 +8,3 @@ export declare const isWin: boolean; | ||
*/ | ||
export declare function pidExists(pid: number): Promise<boolean>; | ||
export declare function pidExists(pid: number | null | undefined): Promise<boolean>; | ||
/** | ||
@@ -23,2 +23,2 @@ * @export | ||
*/ | ||
export declare function kill(pid: number, force?: boolean): void; | ||
export declare function kill(pid: number | null | undefined, force?: boolean): void; |
@@ -46,2 +46,4 @@ "use strict"; | ||
function pidExists(pid) { | ||
if (pid == null) | ||
return Promise.resolve(false); | ||
var needle = safePid(pid); | ||
@@ -88,5 +90,3 @@ var cmd = exports.isWin ? "tasklist" : "ps"; | ||
.map(function (ea) { return ea.match(exports.isWin ? winRe : posixRe); }) | ||
.filter(function (m) { return m != null; }).map(function (m) { | ||
return parseInt(m[1]); | ||
})); | ||
.filter(function (m) { return m != null; }).map(function (m) { return parseInt(m[1]); })); | ||
}); | ||
@@ -106,2 +106,4 @@ }); | ||
if (force === void 0) { force = false; } | ||
if (pid == null) | ||
return; | ||
if (pid === _p.pid || pid === _p.ppid) { | ||
@@ -108,0 +110,0 @@ throw new Error("cannot self-terminate"); |
{ | ||
"name": "batch-cluster", | ||
"version": "6.1.0", | ||
"version": "6.2.0", | ||
"description": "Manage a cluster of child processes", | ||
@@ -37,9 +37,9 @@ "main": "dist/BatchCluster.js", | ||
"devDependencies": { | ||
"@types/chai": "^4.2.17", | ||
"@types/chai-as-promised": "^7.1.3", | ||
"@types/chai": "^4.2.19", | ||
"@types/chai-as-promised": "^7.1.4", | ||
"@types/chai-string": "^1.4.2", | ||
"@types/mocha": "^8.2.2", | ||
"@types/node": "^15.0.1", | ||
"@typescript-eslint/eslint-plugin": "^4.22.0", | ||
"@typescript-eslint/parser": "^4.22.0", | ||
"@types/node": "^15.12.5", | ||
"@typescript-eslint/eslint-plugin": "^4.28.1", | ||
"@typescript-eslint/parser": "^4.28.1", | ||
"chai": "^4.3.4", | ||
@@ -49,15 +49,15 @@ "chai-as-promised": "^7.1.1", | ||
"chai-withintoleranceof": "^1.0.1", | ||
"eslint": "^7.25.0", | ||
"eslint-plugin-import": "^2.22.1", | ||
"mocha": "^8.3.2", | ||
"prettier": "^2.2.1", | ||
"eslint": "^7.29.0", | ||
"eslint-plugin-import": "^2.23.4", | ||
"mocha": "^9.0.1", | ||
"prettier": "^2.3.2", | ||
"rimraf": "^3.0.2", | ||
"seedrandom": "^3.0.5", | ||
"serve": "^11.3.2", | ||
"serve": "^12.0.0", | ||
"source-map-support": "^0.5.19", | ||
"split2": "^3.2.2", | ||
"timekeeper": "^2.2.0", | ||
"typedoc": "^0.20.36", | ||
"typescript": "^4.2.4" | ||
"typedoc": "^0.21.2", | ||
"typescript": "^4.3.5" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
297565
2887