app-bundler 0.2.21 → 0.2.23
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/.circleci/config.yml +37 -37
- package/.editorconfig +8 -8
- package/README.md +33 -33
- package/lib/bundler.js +1893 -1884
- package/lib/cli.js +1893 -1884
- package/package.json +1 -1
- package/todo.txt +2 -2
- package/tools/build.js +58 -58
- package/tools/bundler.js +7075 -7075
- package/tsconfig-build.json +23 -23
- package/tsconfig.json +24 -24
- package/types/color.d.ts +2 -2
- package/typings.json +6 -6
package/lib/cli.js
CHANGED
|
@@ -1312,12 +1312,21 @@ const global_1 = _src_global;
|
|
|
1312
1312
|
var Npm;
|
|
1313
1313
|
(function (Npm) {
|
|
1314
1314
|
function resolveAppUrl(path, currentLocation, opts) {
|
|
1315
|
+
var _a;
|
|
1315
1316
|
let base = opts.base;
|
|
1316
1317
|
let name = /^(@?[^\\\/]+)/.exec(path)[0];
|
|
1318
|
+
let subname = (_a = /^([^\\\/]+)\/([^\\\/]+)/.exec(path)) === null || _a === void 0 ? void 0 : _a[2];
|
|
1317
1319
|
let resource = path.substring(name.length + 1);
|
|
1318
1320
|
while (path != null) {
|
|
1319
1321
|
let dirname = (0, path_1.path_combine)(currentLocation, 'node_modules', name, '/');
|
|
1320
1322
|
let pkg = (0, path_1.path_combine)(dirname, 'package.json');
|
|
1323
|
+
if (subname) {
|
|
1324
|
+
// Resolve also "@foo/bar/qux" as "node_modules/@foo/bar/qux.js"
|
|
1325
|
+
let pkg2 = (0, path_1.path_combine)(dirname, subname, 'package.json');
|
|
1326
|
+
if (global_1.io.File.exists(pkg2)) {
|
|
1327
|
+
pkg = pkg2;
|
|
1328
|
+
}
|
|
1329
|
+
}
|
|
1321
1330
|
if (global_1.io.File.exists(pkg) === false) {
|
|
1322
1331
|
let next = currentLocation.replace(/[^\/]+\/?$/, '');
|
|
1323
1332
|
if (next === currentLocation) {
|
|
@@ -2149,282 +2158,282 @@ var _node_modules_tslib_tslib;
|
|
|
2149
2158
|
var exports = _node_modules_tslib_tslib != null ? _node_modules_tslib_tslib : {};
|
|
2150
2159
|
var module = { exports: exports };
|
|
2151
2160
|
|
|
2152
|
-
/*! *****************************************************************************
|
|
2153
|
-
Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2154
|
-
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
2155
|
-
this file except in compliance with the License. You may obtain a copy of the
|
|
2156
|
-
License at http://www.apache.org/licenses/LICENSE-2.0
|
|
2157
|
-
|
|
2158
|
-
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
2159
|
-
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
|
2160
|
-
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
|
2161
|
-
MERCHANTABLITY OR NON-INFRINGEMENT.
|
|
2162
|
-
|
|
2163
|
-
See the Apache Version 2.0 License for specific language governing permissions
|
|
2164
|
-
and limitations under the License.
|
|
2165
|
-
***************************************************************************** */
|
|
2166
|
-
/* global global, define, System, Reflect, Promise */
|
|
2167
|
-
var __extends;
|
|
2168
|
-
var __assign;
|
|
2169
|
-
var __rest;
|
|
2170
|
-
var __decorate;
|
|
2171
|
-
var __param;
|
|
2172
|
-
var __metadata;
|
|
2173
|
-
var __awaiter;
|
|
2174
|
-
var __generator;
|
|
2175
|
-
var __exportStar;
|
|
2176
|
-
var __values;
|
|
2177
|
-
var __read;
|
|
2178
|
-
var __spread;
|
|
2179
|
-
var __spreadArrays;
|
|
2180
|
-
var __await;
|
|
2181
|
-
var __asyncGenerator;
|
|
2182
|
-
var __asyncDelegator;
|
|
2183
|
-
var __asyncValues;
|
|
2184
|
-
var __makeTemplateObject;
|
|
2185
|
-
var __importStar;
|
|
2186
|
-
var __importDefault;
|
|
2187
|
-
var __classPrivateFieldGet;
|
|
2188
|
-
var __classPrivateFieldSet;
|
|
2189
|
-
(function (factory) {
|
|
2190
|
-
var root = typeof global === "object" ? global : typeof self === "object" ? self : typeof this === "object" ? this : {};
|
|
2191
|
-
if (typeof define === "function" && define.amd) {
|
|
2192
|
-
define("tslib", ["exports"], function (exports) { factory(createExporter(root, createExporter(exports))); });
|
|
2193
|
-
}
|
|
2194
|
-
else if (typeof module === "object" && typeof module.exports === "object") {
|
|
2195
|
-
factory(createExporter(root, createExporter(module.exports)));
|
|
2196
|
-
}
|
|
2197
|
-
else {
|
|
2198
|
-
factory(createExporter(root));
|
|
2199
|
-
}
|
|
2200
|
-
function createExporter(exports, previous) {
|
|
2201
|
-
if (exports !== root) {
|
|
2202
|
-
if (typeof Object.create === "function") {
|
|
2203
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2204
|
-
}
|
|
2205
|
-
else {
|
|
2206
|
-
exports.__esModule = true;
|
|
2207
|
-
}
|
|
2208
|
-
}
|
|
2209
|
-
return function (id, v) { return exports[id] = previous ? previous(id, v) : v; };
|
|
2210
|
-
}
|
|
2211
|
-
})
|
|
2212
|
-
(function (exporter) {
|
|
2213
|
-
var extendStatics = Object.setPrototypeOf ||
|
|
2214
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
2215
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
2216
|
-
|
|
2217
|
-
__extends = function (d, b) {
|
|
2218
|
-
extendStatics(d, b);
|
|
2219
|
-
function __() { this.constructor = d; }
|
|
2220
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
2221
|
-
};
|
|
2222
|
-
|
|
2223
|
-
__assign = Object.assign || function (t) {
|
|
2224
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
2225
|
-
s = arguments[i];
|
|
2226
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
2227
|
-
}
|
|
2228
|
-
return t;
|
|
2229
|
-
};
|
|
2230
|
-
|
|
2231
|
-
__rest = function (s, e) {
|
|
2232
|
-
var t = {};
|
|
2233
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
2234
|
-
t[p] = s[p];
|
|
2235
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
2236
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
2237
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
2238
|
-
t[p[i]] = s[p[i]];
|
|
2239
|
-
}
|
|
2240
|
-
return t;
|
|
2241
|
-
};
|
|
2242
|
-
|
|
2243
|
-
__decorate = function (decorators, target, key, desc) {
|
|
2244
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2245
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2246
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2247
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2248
|
-
};
|
|
2249
|
-
|
|
2250
|
-
__param = function (paramIndex, decorator) {
|
|
2251
|
-
return function (target, key) { decorator(target, key, paramIndex); }
|
|
2252
|
-
};
|
|
2253
|
-
|
|
2254
|
-
__metadata = function (metadataKey, metadataValue) {
|
|
2255
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
|
|
2256
|
-
};
|
|
2257
|
-
|
|
2258
|
-
__awaiter = function (thisArg, _arguments, P, generator) {
|
|
2259
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
2260
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
2261
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
2262
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
2263
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
2264
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
2265
|
-
});
|
|
2266
|
-
};
|
|
2267
|
-
|
|
2268
|
-
__generator = function (thisArg, body) {
|
|
2269
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
2270
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
2271
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
2272
|
-
function step(op) {
|
|
2273
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
2274
|
-
while (_) try {
|
|
2275
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
2276
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
2277
|
-
switch (op[0]) {
|
|
2278
|
-
case 0: case 1: t = op; break;
|
|
2279
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
2280
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
2281
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
2282
|
-
default:
|
|
2283
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
2284
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
2285
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
2286
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
2287
|
-
if (t[2]) _.ops.pop();
|
|
2288
|
-
_.trys.pop(); continue;
|
|
2289
|
-
}
|
|
2290
|
-
op = body.call(thisArg, _);
|
|
2291
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
2292
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
2293
|
-
}
|
|
2294
|
-
};
|
|
2295
|
-
|
|
2296
|
-
__exportStar = function (m, exports) {
|
|
2297
|
-
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
|
2298
|
-
};
|
|
2299
|
-
|
|
2300
|
-
__values = function (o) {
|
|
2301
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
2302
|
-
if (m) return m.call(o);
|
|
2303
|
-
if (o && typeof o.length === "number") return {
|
|
2304
|
-
next: function () {
|
|
2305
|
-
if (o && i >= o.length) o = void 0;
|
|
2306
|
-
return { value: o && o[i++], done: !o };
|
|
2307
|
-
}
|
|
2308
|
-
};
|
|
2309
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
2310
|
-
};
|
|
2311
|
-
|
|
2312
|
-
__read = function (o, n) {
|
|
2313
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
2314
|
-
if (!m) return o;
|
|
2315
|
-
var i = m.call(o), r, ar = [], e;
|
|
2316
|
-
try {
|
|
2317
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
2318
|
-
}
|
|
2319
|
-
catch (error) { e = { error: error }; }
|
|
2320
|
-
finally {
|
|
2321
|
-
try {
|
|
2322
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
2323
|
-
}
|
|
2324
|
-
finally { if (e) throw e.error; }
|
|
2325
|
-
}
|
|
2326
|
-
return ar;
|
|
2327
|
-
};
|
|
2328
|
-
|
|
2329
|
-
__spread = function () {
|
|
2330
|
-
for (var ar = [], i = 0; i < arguments.length; i++)
|
|
2331
|
-
ar = ar.concat(__read(arguments[i]));
|
|
2332
|
-
return ar;
|
|
2333
|
-
};
|
|
2334
|
-
|
|
2335
|
-
__spreadArrays = function () {
|
|
2336
|
-
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
|
2337
|
-
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
2338
|
-
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
2339
|
-
r[k] = a[j];
|
|
2340
|
-
return r;
|
|
2341
|
-
};
|
|
2342
|
-
|
|
2343
|
-
__await = function (v) {
|
|
2344
|
-
return this instanceof __await ? (this.v = v, this) : new __await(v);
|
|
2345
|
-
};
|
|
2346
|
-
|
|
2347
|
-
__asyncGenerator = function (thisArg, _arguments, generator) {
|
|
2348
|
-
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
2349
|
-
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
2350
|
-
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
2351
|
-
function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
|
|
2352
|
-
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
|
2353
|
-
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
2354
|
-
function fulfill(value) { resume("next", value); }
|
|
2355
|
-
function reject(value) { resume("throw", value); }
|
|
2356
|
-
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
|
2357
|
-
};
|
|
2358
|
-
|
|
2359
|
-
__asyncDelegator = function (o) {
|
|
2360
|
-
var i, p;
|
|
2361
|
-
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
|
2362
|
-
function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
|
|
2363
|
-
};
|
|
2364
|
-
|
|
2365
|
-
__asyncValues = function (o) {
|
|
2366
|
-
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
2367
|
-
var m = o[Symbol.asyncIterator], i;
|
|
2368
|
-
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
2369
|
-
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
2370
|
-
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
2371
|
-
};
|
|
2372
|
-
|
|
2373
|
-
__makeTemplateObject = function (cooked, raw) {
|
|
2374
|
-
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
2375
|
-
return cooked;
|
|
2376
|
-
};
|
|
2377
|
-
|
|
2378
|
-
__importStar = function (mod) {
|
|
2379
|
-
if (mod && mod.__esModule) return mod;
|
|
2380
|
-
var result = {};
|
|
2381
|
-
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
2382
|
-
result["default"] = mod;
|
|
2383
|
-
return result;
|
|
2384
|
-
};
|
|
2385
|
-
|
|
2386
|
-
__importDefault = function (mod) {
|
|
2387
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
2388
|
-
};
|
|
2389
|
-
|
|
2390
|
-
__classPrivateFieldGet = function (receiver, privateMap) {
|
|
2391
|
-
if (!privateMap.has(receiver)) {
|
|
2392
|
-
throw new TypeError("attempted to get private field on non-instance");
|
|
2393
|
-
}
|
|
2394
|
-
return privateMap.get(receiver);
|
|
2395
|
-
};
|
|
2396
|
-
|
|
2397
|
-
__classPrivateFieldSet = function (receiver, privateMap, value) {
|
|
2398
|
-
if (!privateMap.has(receiver)) {
|
|
2399
|
-
throw new TypeError("attempted to set private field on non-instance");
|
|
2400
|
-
}
|
|
2401
|
-
privateMap.set(receiver, value);
|
|
2402
|
-
return value;
|
|
2403
|
-
}
|
|
2404
|
-
|
|
2405
|
-
exporter("__extends", __extends);
|
|
2406
|
-
exporter("__assign", __assign);
|
|
2407
|
-
exporter("__rest", __rest);
|
|
2408
|
-
exporter("__decorate", __decorate);
|
|
2409
|
-
exporter("__param", __param);
|
|
2410
|
-
exporter("__metadata", __metadata);
|
|
2411
|
-
exporter("__awaiter", __awaiter);
|
|
2412
|
-
exporter("__generator", __generator);
|
|
2413
|
-
exporter("__exportStar", __exportStar);
|
|
2414
|
-
exporter("__values", __values);
|
|
2415
|
-
exporter("__read", __read);
|
|
2416
|
-
exporter("__spread", __spread);
|
|
2417
|
-
exporter("__spreadArrays", __spreadArrays);
|
|
2418
|
-
exporter("__await", __await);
|
|
2419
|
-
exporter("__asyncGenerator", __asyncGenerator);
|
|
2420
|
-
exporter("__asyncDelegator", __asyncDelegator);
|
|
2421
|
-
exporter("__asyncValues", __asyncValues);
|
|
2422
|
-
exporter("__makeTemplateObject", __makeTemplateObject);
|
|
2423
|
-
exporter("__importStar", __importStar);
|
|
2424
|
-
exporter("__importDefault", __importDefault);
|
|
2425
|
-
exporter("__classPrivateFieldGet", __classPrivateFieldGet);
|
|
2426
|
-
exporter("__classPrivateFieldSet", __classPrivateFieldSet);
|
|
2427
|
-
});
|
|
2161
|
+
/*! *****************************************************************************
|
|
2162
|
+
Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2163
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
2164
|
+
this file except in compliance with the License. You may obtain a copy of the
|
|
2165
|
+
License at http://www.apache.org/licenses/LICENSE-2.0
|
|
2166
|
+
|
|
2167
|
+
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
2168
|
+
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
|
2169
|
+
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
|
2170
|
+
MERCHANTABLITY OR NON-INFRINGEMENT.
|
|
2171
|
+
|
|
2172
|
+
See the Apache Version 2.0 License for specific language governing permissions
|
|
2173
|
+
and limitations under the License.
|
|
2174
|
+
***************************************************************************** */
|
|
2175
|
+
/* global global, define, System, Reflect, Promise */
|
|
2176
|
+
var __extends;
|
|
2177
|
+
var __assign;
|
|
2178
|
+
var __rest;
|
|
2179
|
+
var __decorate;
|
|
2180
|
+
var __param;
|
|
2181
|
+
var __metadata;
|
|
2182
|
+
var __awaiter;
|
|
2183
|
+
var __generator;
|
|
2184
|
+
var __exportStar;
|
|
2185
|
+
var __values;
|
|
2186
|
+
var __read;
|
|
2187
|
+
var __spread;
|
|
2188
|
+
var __spreadArrays;
|
|
2189
|
+
var __await;
|
|
2190
|
+
var __asyncGenerator;
|
|
2191
|
+
var __asyncDelegator;
|
|
2192
|
+
var __asyncValues;
|
|
2193
|
+
var __makeTemplateObject;
|
|
2194
|
+
var __importStar;
|
|
2195
|
+
var __importDefault;
|
|
2196
|
+
var __classPrivateFieldGet;
|
|
2197
|
+
var __classPrivateFieldSet;
|
|
2198
|
+
(function (factory) {
|
|
2199
|
+
var root = typeof global === "object" ? global : typeof self === "object" ? self : typeof this === "object" ? this : {};
|
|
2200
|
+
if (typeof define === "function" && define.amd) {
|
|
2201
|
+
define("tslib", ["exports"], function (exports) { factory(createExporter(root, createExporter(exports))); });
|
|
2202
|
+
}
|
|
2203
|
+
else if (typeof module === "object" && typeof module.exports === "object") {
|
|
2204
|
+
factory(createExporter(root, createExporter(module.exports)));
|
|
2205
|
+
}
|
|
2206
|
+
else {
|
|
2207
|
+
factory(createExporter(root));
|
|
2208
|
+
}
|
|
2209
|
+
function createExporter(exports, previous) {
|
|
2210
|
+
if (exports !== root) {
|
|
2211
|
+
if (typeof Object.create === "function") {
|
|
2212
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2213
|
+
}
|
|
2214
|
+
else {
|
|
2215
|
+
exports.__esModule = true;
|
|
2216
|
+
}
|
|
2217
|
+
}
|
|
2218
|
+
return function (id, v) { return exports[id] = previous ? previous(id, v) : v; };
|
|
2219
|
+
}
|
|
2220
|
+
})
|
|
2221
|
+
(function (exporter) {
|
|
2222
|
+
var extendStatics = Object.setPrototypeOf ||
|
|
2223
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
2224
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
2225
|
+
|
|
2226
|
+
__extends = function (d, b) {
|
|
2227
|
+
extendStatics(d, b);
|
|
2228
|
+
function __() { this.constructor = d; }
|
|
2229
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
2230
|
+
};
|
|
2231
|
+
|
|
2232
|
+
__assign = Object.assign || function (t) {
|
|
2233
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
2234
|
+
s = arguments[i];
|
|
2235
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
2236
|
+
}
|
|
2237
|
+
return t;
|
|
2238
|
+
};
|
|
2239
|
+
|
|
2240
|
+
__rest = function (s, e) {
|
|
2241
|
+
var t = {};
|
|
2242
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
2243
|
+
t[p] = s[p];
|
|
2244
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
2245
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
2246
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
2247
|
+
t[p[i]] = s[p[i]];
|
|
2248
|
+
}
|
|
2249
|
+
return t;
|
|
2250
|
+
};
|
|
2251
|
+
|
|
2252
|
+
__decorate = function (decorators, target, key, desc) {
|
|
2253
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2254
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2255
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2256
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2257
|
+
};
|
|
2258
|
+
|
|
2259
|
+
__param = function (paramIndex, decorator) {
|
|
2260
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
2261
|
+
};
|
|
2262
|
+
|
|
2263
|
+
__metadata = function (metadataKey, metadataValue) {
|
|
2264
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
|
|
2265
|
+
};
|
|
2266
|
+
|
|
2267
|
+
__awaiter = function (thisArg, _arguments, P, generator) {
|
|
2268
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
2269
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
2270
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
2271
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
2272
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
2273
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
2274
|
+
});
|
|
2275
|
+
};
|
|
2276
|
+
|
|
2277
|
+
__generator = function (thisArg, body) {
|
|
2278
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
2279
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
2280
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
2281
|
+
function step(op) {
|
|
2282
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
2283
|
+
while (_) try {
|
|
2284
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
2285
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
2286
|
+
switch (op[0]) {
|
|
2287
|
+
case 0: case 1: t = op; break;
|
|
2288
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
2289
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
2290
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
2291
|
+
default:
|
|
2292
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
2293
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
2294
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
2295
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
2296
|
+
if (t[2]) _.ops.pop();
|
|
2297
|
+
_.trys.pop(); continue;
|
|
2298
|
+
}
|
|
2299
|
+
op = body.call(thisArg, _);
|
|
2300
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
2301
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
2302
|
+
}
|
|
2303
|
+
};
|
|
2304
|
+
|
|
2305
|
+
__exportStar = function (m, exports) {
|
|
2306
|
+
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
|
2307
|
+
};
|
|
2308
|
+
|
|
2309
|
+
__values = function (o) {
|
|
2310
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
2311
|
+
if (m) return m.call(o);
|
|
2312
|
+
if (o && typeof o.length === "number") return {
|
|
2313
|
+
next: function () {
|
|
2314
|
+
if (o && i >= o.length) o = void 0;
|
|
2315
|
+
return { value: o && o[i++], done: !o };
|
|
2316
|
+
}
|
|
2317
|
+
};
|
|
2318
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
2319
|
+
};
|
|
2320
|
+
|
|
2321
|
+
__read = function (o, n) {
|
|
2322
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
2323
|
+
if (!m) return o;
|
|
2324
|
+
var i = m.call(o), r, ar = [], e;
|
|
2325
|
+
try {
|
|
2326
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
2327
|
+
}
|
|
2328
|
+
catch (error) { e = { error: error }; }
|
|
2329
|
+
finally {
|
|
2330
|
+
try {
|
|
2331
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
2332
|
+
}
|
|
2333
|
+
finally { if (e) throw e.error; }
|
|
2334
|
+
}
|
|
2335
|
+
return ar;
|
|
2336
|
+
};
|
|
2337
|
+
|
|
2338
|
+
__spread = function () {
|
|
2339
|
+
for (var ar = [], i = 0; i < arguments.length; i++)
|
|
2340
|
+
ar = ar.concat(__read(arguments[i]));
|
|
2341
|
+
return ar;
|
|
2342
|
+
};
|
|
2343
|
+
|
|
2344
|
+
__spreadArrays = function () {
|
|
2345
|
+
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
|
2346
|
+
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
2347
|
+
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
2348
|
+
r[k] = a[j];
|
|
2349
|
+
return r;
|
|
2350
|
+
};
|
|
2351
|
+
|
|
2352
|
+
__await = function (v) {
|
|
2353
|
+
return this instanceof __await ? (this.v = v, this) : new __await(v);
|
|
2354
|
+
};
|
|
2355
|
+
|
|
2356
|
+
__asyncGenerator = function (thisArg, _arguments, generator) {
|
|
2357
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
2358
|
+
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
2359
|
+
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
2360
|
+
function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
|
|
2361
|
+
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
|
2362
|
+
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
2363
|
+
function fulfill(value) { resume("next", value); }
|
|
2364
|
+
function reject(value) { resume("throw", value); }
|
|
2365
|
+
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
|
2366
|
+
};
|
|
2367
|
+
|
|
2368
|
+
__asyncDelegator = function (o) {
|
|
2369
|
+
var i, p;
|
|
2370
|
+
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
|
2371
|
+
function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
|
|
2372
|
+
};
|
|
2373
|
+
|
|
2374
|
+
__asyncValues = function (o) {
|
|
2375
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
2376
|
+
var m = o[Symbol.asyncIterator], i;
|
|
2377
|
+
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
2378
|
+
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
2379
|
+
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
2380
|
+
};
|
|
2381
|
+
|
|
2382
|
+
__makeTemplateObject = function (cooked, raw) {
|
|
2383
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
2384
|
+
return cooked;
|
|
2385
|
+
};
|
|
2386
|
+
|
|
2387
|
+
__importStar = function (mod) {
|
|
2388
|
+
if (mod && mod.__esModule) return mod;
|
|
2389
|
+
var result = {};
|
|
2390
|
+
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
2391
|
+
result["default"] = mod;
|
|
2392
|
+
return result;
|
|
2393
|
+
};
|
|
2394
|
+
|
|
2395
|
+
__importDefault = function (mod) {
|
|
2396
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
2397
|
+
};
|
|
2398
|
+
|
|
2399
|
+
__classPrivateFieldGet = function (receiver, privateMap) {
|
|
2400
|
+
if (!privateMap.has(receiver)) {
|
|
2401
|
+
throw new TypeError("attempted to get private field on non-instance");
|
|
2402
|
+
}
|
|
2403
|
+
return privateMap.get(receiver);
|
|
2404
|
+
};
|
|
2405
|
+
|
|
2406
|
+
__classPrivateFieldSet = function (receiver, privateMap, value) {
|
|
2407
|
+
if (!privateMap.has(receiver)) {
|
|
2408
|
+
throw new TypeError("attempted to set private field on non-instance");
|
|
2409
|
+
}
|
|
2410
|
+
privateMap.set(receiver, value);
|
|
2411
|
+
return value;
|
|
2412
|
+
}
|
|
2413
|
+
|
|
2414
|
+
exporter("__extends", __extends);
|
|
2415
|
+
exporter("__assign", __assign);
|
|
2416
|
+
exporter("__rest", __rest);
|
|
2417
|
+
exporter("__decorate", __decorate);
|
|
2418
|
+
exporter("__param", __param);
|
|
2419
|
+
exporter("__metadata", __metadata);
|
|
2420
|
+
exporter("__awaiter", __awaiter);
|
|
2421
|
+
exporter("__generator", __generator);
|
|
2422
|
+
exporter("__exportStar", __exportStar);
|
|
2423
|
+
exporter("__values", __values);
|
|
2424
|
+
exporter("__read", __read);
|
|
2425
|
+
exporter("__spread", __spread);
|
|
2426
|
+
exporter("__spreadArrays", __spreadArrays);
|
|
2427
|
+
exporter("__await", __await);
|
|
2428
|
+
exporter("__asyncGenerator", __asyncGenerator);
|
|
2429
|
+
exporter("__asyncDelegator", __asyncDelegator);
|
|
2430
|
+
exporter("__asyncValues", __asyncValues);
|
|
2431
|
+
exporter("__makeTemplateObject", __makeTemplateObject);
|
|
2432
|
+
exporter("__importStar", __importStar);
|
|
2433
|
+
exporter("__importDefault", __importDefault);
|
|
2434
|
+
exporter("__classPrivateFieldGet", __classPrivateFieldGet);
|
|
2435
|
+
exporter("__classPrivateFieldSet", __classPrivateFieldSet);
|
|
2436
|
+
});
|
|
2428
2437
|
;
|
|
2429
2438
|
|
|
2430
2439
|
function __isObj(x) {
|
|
@@ -10349,18 +10358,18 @@ var _src_util_path;
|
|
|
10349
10358
|
var exports = _src_util_path != null ? _src_util_path : {};
|
|
10350
10359
|
var module = { exports: exports };
|
|
10351
10360
|
|
|
10352
|
-
"use strict";
|
|
10353
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10354
|
-
exports.path_ensure = void 0;
|
|
10355
|
-
var atma_utils_1 = require("atma-utils");
|
|
10356
|
-
function path_ensure(cwd, base) {
|
|
10357
|
-
if (cwd[0] !== '/' && new atma_utils_1.class_Uri(cwd).isRelative()) {
|
|
10358
|
-
var x = require('path').normalize(atma_utils_1.class_Uri.combine(base, cwd));
|
|
10359
|
-
return x;
|
|
10360
|
-
}
|
|
10361
|
-
return cwd;
|
|
10362
|
-
}
|
|
10363
|
-
exports.path_ensure = path_ensure;
|
|
10361
|
+
"use strict";
|
|
10362
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10363
|
+
exports.path_ensure = void 0;
|
|
10364
|
+
var atma_utils_1 = require("atma-utils");
|
|
10365
|
+
function path_ensure(cwd, base) {
|
|
10366
|
+
if (cwd[0] !== '/' && new atma_utils_1.class_Uri(cwd).isRelative()) {
|
|
10367
|
+
var x = require('path').normalize(atma_utils_1.class_Uri.combine(base, cwd));
|
|
10368
|
+
return x;
|
|
10369
|
+
}
|
|
10370
|
+
return cwd;
|
|
10371
|
+
}
|
|
10372
|
+
exports.path_ensure = path_ensure;
|
|
10364
10373
|
;
|
|
10365
10374
|
|
|
10366
10375
|
function __isObj(x) {
|
|
@@ -10388,64 +10397,64 @@ var _src_util_ShellWrapperUtil;
|
|
|
10388
10397
|
var exports = _src_util_ShellWrapperUtil != null ? _src_util_ShellWrapperUtil : {};
|
|
10389
10398
|
var module = { exports: exports };
|
|
10390
10399
|
|
|
10391
|
-
"use strict";
|
|
10392
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
10393
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
10394
|
-
if (ar || !(i in from)) {
|
|
10395
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
10396
|
-
ar[i] = from[i];
|
|
10397
|
-
}
|
|
10398
|
-
}
|
|
10399
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
10400
|
-
};
|
|
10401
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10402
|
-
exports.ShellWrapperUtil = void 0;
|
|
10403
|
-
var COMMAND_PLACEHOLDER = '%COMMAND%';
|
|
10404
|
-
var ShellWrapperUtil;
|
|
10405
|
-
(function (ShellWrapperUtil) {
|
|
10406
|
-
function prefix(args, config) {
|
|
10407
|
-
if (!(config === null || config === void 0 ? void 0 : config.shell)) {
|
|
10408
|
-
return args;
|
|
10409
|
-
}
|
|
10410
|
-
if (Array.isArray(config.shell) === false) {
|
|
10411
|
-
throw new Error("We can prefix only array of strings(argumnets)");
|
|
10412
|
-
return;
|
|
10413
|
-
}
|
|
10414
|
-
var _a = config.shell, exec = _a[0], rest = _a.slice(1);
|
|
10415
|
-
return __spreadArray(__spreadArray([exec], rest, true), args, true);
|
|
10416
|
-
}
|
|
10417
|
-
ShellWrapperUtil.prefix = prefix;
|
|
10418
|
-
function wrap(command, config) {
|
|
10419
|
-
if (!(config === null || config === void 0 ? void 0 : config.shell)) {
|
|
10420
|
-
return command;
|
|
10421
|
-
}
|
|
10422
|
-
if (typeof config.shell !== 'string') {
|
|
10423
|
-
throw new Error("We can wrap only as command template");
|
|
10424
|
-
return;
|
|
10425
|
-
}
|
|
10426
|
-
if (command.includes('"') === false) {
|
|
10427
|
-
command = "\"".concat(command, "\"");
|
|
10428
|
-
}
|
|
10429
|
-
else if (command.includes("'") === false) {
|
|
10430
|
-
command = "'".concat(command, "'");
|
|
10431
|
-
}
|
|
10432
|
-
else {
|
|
10433
|
-
throw new Error("Command can't be quoted, as both already present");
|
|
10434
|
-
}
|
|
10435
|
-
return config.shell.replace(COMMAND_PLACEHOLDER, command);
|
|
10436
|
-
}
|
|
10437
|
-
ShellWrapperUtil.wrap = wrap;
|
|
10438
|
-
// [cmd, /c, ...command]
|
|
10439
|
-
function isPrefix(shell) {
|
|
10440
|
-
return shell != null && Array.isArray(shell);
|
|
10441
|
-
}
|
|
10442
|
-
ShellWrapperUtil.isPrefix = isPrefix;
|
|
10443
|
-
// bash.exe -c %COMMAND%
|
|
10444
|
-
function isWrapper(shell) {
|
|
10445
|
-
return shell != null && typeof shell === 'string' && shell.includes(COMMAND_PLACEHOLDER);
|
|
10446
|
-
}
|
|
10447
|
-
ShellWrapperUtil.isWrapper = isWrapper;
|
|
10448
|
-
})(ShellWrapperUtil = exports.ShellWrapperUtil || (exports.ShellWrapperUtil = {}));
|
|
10400
|
+
"use strict";
|
|
10401
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
10402
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
10403
|
+
if (ar || !(i in from)) {
|
|
10404
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
10405
|
+
ar[i] = from[i];
|
|
10406
|
+
}
|
|
10407
|
+
}
|
|
10408
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
10409
|
+
};
|
|
10410
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10411
|
+
exports.ShellWrapperUtil = void 0;
|
|
10412
|
+
var COMMAND_PLACEHOLDER = '%COMMAND%';
|
|
10413
|
+
var ShellWrapperUtil;
|
|
10414
|
+
(function (ShellWrapperUtil) {
|
|
10415
|
+
function prefix(args, config) {
|
|
10416
|
+
if (!(config === null || config === void 0 ? void 0 : config.shell)) {
|
|
10417
|
+
return args;
|
|
10418
|
+
}
|
|
10419
|
+
if (Array.isArray(config.shell) === false) {
|
|
10420
|
+
throw new Error("We can prefix only array of strings(argumnets)");
|
|
10421
|
+
return;
|
|
10422
|
+
}
|
|
10423
|
+
var _a = config.shell, exec = _a[0], rest = _a.slice(1);
|
|
10424
|
+
return __spreadArray(__spreadArray([exec], rest, true), args, true);
|
|
10425
|
+
}
|
|
10426
|
+
ShellWrapperUtil.prefix = prefix;
|
|
10427
|
+
function wrap(command, config) {
|
|
10428
|
+
if (!(config === null || config === void 0 ? void 0 : config.shell)) {
|
|
10429
|
+
return command;
|
|
10430
|
+
}
|
|
10431
|
+
if (typeof config.shell !== 'string') {
|
|
10432
|
+
throw new Error("We can wrap only as command template");
|
|
10433
|
+
return;
|
|
10434
|
+
}
|
|
10435
|
+
if (command.includes('"') === false) {
|
|
10436
|
+
command = "\"".concat(command, "\"");
|
|
10437
|
+
}
|
|
10438
|
+
else if (command.includes("'") === false) {
|
|
10439
|
+
command = "'".concat(command, "'");
|
|
10440
|
+
}
|
|
10441
|
+
else {
|
|
10442
|
+
throw new Error("Command can't be quoted, as both already present");
|
|
10443
|
+
}
|
|
10444
|
+
return config.shell.replace(COMMAND_PLACEHOLDER, command);
|
|
10445
|
+
}
|
|
10446
|
+
ShellWrapperUtil.wrap = wrap;
|
|
10447
|
+
// [cmd, /c, ...command]
|
|
10448
|
+
function isPrefix(shell) {
|
|
10449
|
+
return shell != null && Array.isArray(shell);
|
|
10450
|
+
}
|
|
10451
|
+
ShellWrapperUtil.isPrefix = isPrefix;
|
|
10452
|
+
// bash.exe -c %COMMAND%
|
|
10453
|
+
function isWrapper(shell) {
|
|
10454
|
+
return shell != null && typeof shell === 'string' && shell.includes(COMMAND_PLACEHOLDER);
|
|
10455
|
+
}
|
|
10456
|
+
ShellWrapperUtil.isWrapper = isWrapper;
|
|
10457
|
+
})(ShellWrapperUtil = exports.ShellWrapperUtil || (exports.ShellWrapperUtil = {}));
|
|
10449
10458
|
;
|
|
10450
10459
|
|
|
10451
10460
|
function __isObj(x) {
|
|
@@ -10473,84 +10482,84 @@ var _src_util_command;
|
|
|
10473
10482
|
var exports = _src_util_command != null ? _src_util_command : {};
|
|
10474
10483
|
var module = { exports: exports };
|
|
10475
10484
|
|
|
10476
|
-
"use strict";
|
|
10477
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10478
|
-
exports.command_parseAll = void 0;
|
|
10479
|
-
var path_1 = _src_util_path;
|
|
10480
|
-
var ShellWrapperUtil_1 = _src_util_ShellWrapperUtil;
|
|
10481
|
-
function command_parseAll(commands, params) {
|
|
10482
|
-
var _a;
|
|
10483
|
-
var cwdAll = (_a = params.cwd) !== null && _a !== void 0 ? _a : process.cwd();
|
|
10484
|
-
cwdAll = (0, path_1.path_ensure)(cwdAll, process.cwd());
|
|
10485
|
-
return commands.map(function (command) {
|
|
10486
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
10487
|
-
var opts = typeof command === 'string' ? {
|
|
10488
|
-
exec: command
|
|
10489
|
-
} : command;
|
|
10490
|
-
if (opts.cwd) {
|
|
10491
|
-
opts.cwd = (0, path_1.path_ensure)(opts.cwd, cwdAll !== null && cwdAll !== void 0 ? cwdAll : process.cwd());
|
|
10492
|
-
}
|
|
10493
|
-
var exec = opts.exec;
|
|
10494
|
-
if (exec == null || exec === '') {
|
|
10495
|
-
console.warn('Command Object is not valid. Should be at least {command: string}');
|
|
10496
|
-
return null;
|
|
10497
|
-
}
|
|
10498
|
-
var args = command_parse(exec, params);
|
|
10499
|
-
return {
|
|
10500
|
-
exec: args.shift(),
|
|
10501
|
-
args: args,
|
|
10502
|
-
cwd: (_b = (_a = opts.cwd) !== null && _a !== void 0 ? _a : cwdAll) !== null && _b !== void 0 ? _b : process.cwd(),
|
|
10503
|
-
//stdio: 'pipe',
|
|
10504
|
-
detached: (_d = (_c = opts.detached) !== null && _c !== void 0 ? _c : params.detached) !== null && _d !== void 0 ? _d : false,
|
|
10505
|
-
command: exec,
|
|
10506
|
-
matchReady: (_e = opts.matchReady) !== null && _e !== void 0 ? _e : params.matchReady,
|
|
10507
|
-
extract: opts.extract,
|
|
10508
|
-
fork: (_g = (_f = opts.fork) !== null && _f !== void 0 ? _f : params.fork) !== null && _g !== void 0 ? _g : false,
|
|
10509
|
-
ipc: (_j = (_h = opts.ipc) !== null && _h !== void 0 ? _h : params.ipc) !== null && _j !== void 0 ? _j : false,
|
|
10510
|
-
};
|
|
10511
|
-
}).filter(function (x) { return x != null; });
|
|
10512
|
-
}
|
|
10513
|
-
exports.command_parseAll = command_parseAll;
|
|
10514
|
-
function command_parse(command, params) {
|
|
10515
|
-
if (ShellWrapperUtil_1.ShellWrapperUtil.isWrapper(params.shell)) {
|
|
10516
|
-
command = ShellWrapperUtil_1.ShellWrapperUtil.wrap(command, params);
|
|
10517
|
-
}
|
|
10518
|
-
var parts = command.trim().split(/\s+/);
|
|
10519
|
-
var imax = parts.length;
|
|
10520
|
-
var i = -1;
|
|
10521
|
-
while (++i < imax) {
|
|
10522
|
-
var arg = parts[i];
|
|
10523
|
-
if (arg.length === 0) {
|
|
10524
|
-
continue;
|
|
10525
|
-
}
|
|
10526
|
-
var c = arg[0];
|
|
10527
|
-
if (c !== '"' && c !== "'") {
|
|
10528
|
-
continue;
|
|
10529
|
-
}
|
|
10530
|
-
var start = i;
|
|
10531
|
-
for (; i < imax; i++) {
|
|
10532
|
-
arg = parts[i];
|
|
10533
|
-
if (arg[arg.length - 1] === c) {
|
|
10534
|
-
var str = parts
|
|
10535
|
-
.splice(start, i - start + 1)
|
|
10536
|
-
.join(' ')
|
|
10537
|
-
.slice(1, -1);
|
|
10538
|
-
parts.splice(start, 0, str);
|
|
10539
|
-
imax = parts.length;
|
|
10540
|
-
i--;
|
|
10541
|
-
break;
|
|
10542
|
-
}
|
|
10543
|
-
}
|
|
10544
|
-
}
|
|
10545
|
-
// On windows normalize executable command path to backward slashes
|
|
10546
|
-
if (global.process.platform === 'win32') {
|
|
10547
|
-
parts[0] = parts[0].replace(/\//g, '\\');
|
|
10548
|
-
}
|
|
10549
|
-
if (ShellWrapperUtil_1.ShellWrapperUtil.isPrefix(params.shell)) {
|
|
10550
|
-
parts = ShellWrapperUtil_1.ShellWrapperUtil.prefix(parts, params);
|
|
10551
|
-
}
|
|
10552
|
-
return parts;
|
|
10553
|
-
}
|
|
10485
|
+
"use strict";
|
|
10486
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10487
|
+
exports.command_parseAll = void 0;
|
|
10488
|
+
var path_1 = _src_util_path;
|
|
10489
|
+
var ShellWrapperUtil_1 = _src_util_ShellWrapperUtil;
|
|
10490
|
+
function command_parseAll(commands, params) {
|
|
10491
|
+
var _a;
|
|
10492
|
+
var cwdAll = (_a = params.cwd) !== null && _a !== void 0 ? _a : process.cwd();
|
|
10493
|
+
cwdAll = (0, path_1.path_ensure)(cwdAll, process.cwd());
|
|
10494
|
+
return commands.map(function (command) {
|
|
10495
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
10496
|
+
var opts = typeof command === 'string' ? {
|
|
10497
|
+
exec: command
|
|
10498
|
+
} : command;
|
|
10499
|
+
if (opts.cwd) {
|
|
10500
|
+
opts.cwd = (0, path_1.path_ensure)(opts.cwd, cwdAll !== null && cwdAll !== void 0 ? cwdAll : process.cwd());
|
|
10501
|
+
}
|
|
10502
|
+
var exec = opts.exec;
|
|
10503
|
+
if (exec == null || exec === '') {
|
|
10504
|
+
console.warn('Command Object is not valid. Should be at least {command: string}');
|
|
10505
|
+
return null;
|
|
10506
|
+
}
|
|
10507
|
+
var args = command_parse(exec, params);
|
|
10508
|
+
return {
|
|
10509
|
+
exec: args.shift(),
|
|
10510
|
+
args: args,
|
|
10511
|
+
cwd: (_b = (_a = opts.cwd) !== null && _a !== void 0 ? _a : cwdAll) !== null && _b !== void 0 ? _b : process.cwd(),
|
|
10512
|
+
//stdio: 'pipe',
|
|
10513
|
+
detached: (_d = (_c = opts.detached) !== null && _c !== void 0 ? _c : params.detached) !== null && _d !== void 0 ? _d : false,
|
|
10514
|
+
command: exec,
|
|
10515
|
+
matchReady: (_e = opts.matchReady) !== null && _e !== void 0 ? _e : params.matchReady,
|
|
10516
|
+
extract: opts.extract,
|
|
10517
|
+
fork: (_g = (_f = opts.fork) !== null && _f !== void 0 ? _f : params.fork) !== null && _g !== void 0 ? _g : false,
|
|
10518
|
+
ipc: (_j = (_h = opts.ipc) !== null && _h !== void 0 ? _h : params.ipc) !== null && _j !== void 0 ? _j : false,
|
|
10519
|
+
};
|
|
10520
|
+
}).filter(function (x) { return x != null; });
|
|
10521
|
+
}
|
|
10522
|
+
exports.command_parseAll = command_parseAll;
|
|
10523
|
+
function command_parse(command, params) {
|
|
10524
|
+
if (ShellWrapperUtil_1.ShellWrapperUtil.isWrapper(params.shell)) {
|
|
10525
|
+
command = ShellWrapperUtil_1.ShellWrapperUtil.wrap(command, params);
|
|
10526
|
+
}
|
|
10527
|
+
var parts = command.trim().split(/\s+/);
|
|
10528
|
+
var imax = parts.length;
|
|
10529
|
+
var i = -1;
|
|
10530
|
+
while (++i < imax) {
|
|
10531
|
+
var arg = parts[i];
|
|
10532
|
+
if (arg.length === 0) {
|
|
10533
|
+
continue;
|
|
10534
|
+
}
|
|
10535
|
+
var c = arg[0];
|
|
10536
|
+
if (c !== '"' && c !== "'") {
|
|
10537
|
+
continue;
|
|
10538
|
+
}
|
|
10539
|
+
var start = i;
|
|
10540
|
+
for (; i < imax; i++) {
|
|
10541
|
+
arg = parts[i];
|
|
10542
|
+
if (arg[arg.length - 1] === c) {
|
|
10543
|
+
var str = parts
|
|
10544
|
+
.splice(start, i - start + 1)
|
|
10545
|
+
.join(' ')
|
|
10546
|
+
.slice(1, -1);
|
|
10547
|
+
parts.splice(start, 0, str);
|
|
10548
|
+
imax = parts.length;
|
|
10549
|
+
i--;
|
|
10550
|
+
break;
|
|
10551
|
+
}
|
|
10552
|
+
}
|
|
10553
|
+
}
|
|
10554
|
+
// On windows normalize executable command path to backward slashes
|
|
10555
|
+
if (global.process.platform === 'win32') {
|
|
10556
|
+
parts[0] = parts[0].replace(/\//g, '\\');
|
|
10557
|
+
}
|
|
10558
|
+
if (ShellWrapperUtil_1.ShellWrapperUtil.isPrefix(params.shell)) {
|
|
10559
|
+
parts = ShellWrapperUtil_1.ShellWrapperUtil.prefix(parts, params);
|
|
10560
|
+
}
|
|
10561
|
+
return parts;
|
|
10562
|
+
}
|
|
10554
10563
|
;
|
|
10555
10564
|
|
|
10556
10565
|
function __isObj(x) {
|
|
@@ -10578,60 +10587,60 @@ var _src_ValueExtractor;
|
|
|
10578
10587
|
var exports = _src_ValueExtractor != null ? _src_ValueExtractor : {};
|
|
10579
10588
|
var module = { exports: exports };
|
|
10580
10589
|
|
|
10581
|
-
"use strict";
|
|
10582
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10583
|
-
exports.ValueExtractor = void 0;
|
|
10584
|
-
var atma_utils_1 = require("atma-utils");
|
|
10585
|
-
var ValueExtractor = /** @class */ (function () {
|
|
10586
|
-
function ValueExtractor(target, extractors) {
|
|
10587
|
-
this.target = target;
|
|
10588
|
-
this.extractors = extractors;
|
|
10589
|
-
this.string = '';
|
|
10590
|
-
this.string = '';
|
|
10591
|
-
}
|
|
10592
|
-
ValueExtractor.prototype.write = function (buffer) {
|
|
10593
|
-
this.string += buffer.toString();
|
|
10594
|
-
};
|
|
10595
|
-
ValueExtractor.prototype.complete = function () {
|
|
10596
|
-
for (var key in this.extractors) {
|
|
10597
|
-
this.target[key] = (0, atma_utils_1.is_Function)(this.extractors[key])
|
|
10598
|
-
? this.extractors[key](this.string)
|
|
10599
|
-
: null;
|
|
10600
|
-
}
|
|
10601
|
-
};
|
|
10602
|
-
ValueExtractor.extract = function (str, mix) {
|
|
10603
|
-
if (typeof mix === 'function') {
|
|
10604
|
-
return mix(str);
|
|
10605
|
-
}
|
|
10606
|
-
};
|
|
10607
|
-
ValueExtractor.interpolateAny = function (mix, values, options) {
|
|
10608
|
-
if (mix == null || (options === null || options === void 0 ? void 0 : options.interpolate) === false) {
|
|
10609
|
-
return mix;
|
|
10610
|
-
}
|
|
10611
|
-
if (typeof mix === 'string') {
|
|
10612
|
-
return ValueExtractor.interpolateStr(mix, values);
|
|
10613
|
-
}
|
|
10614
|
-
if (typeof mix.map === 'function') {
|
|
10615
|
-
// isArrayLike
|
|
10616
|
-
return mix.map(function (str) {
|
|
10617
|
-
return ValueExtractor.interpolateAny(str, values, options);
|
|
10618
|
-
});
|
|
10619
|
-
}
|
|
10620
|
-
return mix;
|
|
10621
|
-
};
|
|
10622
|
-
ValueExtractor.interpolateStr = function (str, values) {
|
|
10623
|
-
return str.replace(/\{\{(\w+)\}\}/g, function (full, prop) {
|
|
10624
|
-
var val = values[prop];
|
|
10625
|
-
if (val == null) {
|
|
10626
|
-
console.warn('Extracted property expected: ', prop, values);
|
|
10627
|
-
return '';
|
|
10628
|
-
}
|
|
10629
|
-
return val;
|
|
10630
|
-
});
|
|
10631
|
-
};
|
|
10632
|
-
return ValueExtractor;
|
|
10633
|
-
}());
|
|
10634
|
-
exports.ValueExtractor = ValueExtractor;
|
|
10590
|
+
"use strict";
|
|
10591
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10592
|
+
exports.ValueExtractor = void 0;
|
|
10593
|
+
var atma_utils_1 = require("atma-utils");
|
|
10594
|
+
var ValueExtractor = /** @class */ (function () {
|
|
10595
|
+
function ValueExtractor(target, extractors) {
|
|
10596
|
+
this.target = target;
|
|
10597
|
+
this.extractors = extractors;
|
|
10598
|
+
this.string = '';
|
|
10599
|
+
this.string = '';
|
|
10600
|
+
}
|
|
10601
|
+
ValueExtractor.prototype.write = function (buffer) {
|
|
10602
|
+
this.string += buffer.toString();
|
|
10603
|
+
};
|
|
10604
|
+
ValueExtractor.prototype.complete = function () {
|
|
10605
|
+
for (var key in this.extractors) {
|
|
10606
|
+
this.target[key] = (0, atma_utils_1.is_Function)(this.extractors[key])
|
|
10607
|
+
? this.extractors[key](this.string)
|
|
10608
|
+
: null;
|
|
10609
|
+
}
|
|
10610
|
+
};
|
|
10611
|
+
ValueExtractor.extract = function (str, mix) {
|
|
10612
|
+
if (typeof mix === 'function') {
|
|
10613
|
+
return mix(str);
|
|
10614
|
+
}
|
|
10615
|
+
};
|
|
10616
|
+
ValueExtractor.interpolateAny = function (mix, values, options) {
|
|
10617
|
+
if (mix == null || (options === null || options === void 0 ? void 0 : options.interpolate) === false) {
|
|
10618
|
+
return mix;
|
|
10619
|
+
}
|
|
10620
|
+
if (typeof mix === 'string') {
|
|
10621
|
+
return ValueExtractor.interpolateStr(mix, values);
|
|
10622
|
+
}
|
|
10623
|
+
if (typeof mix.map === 'function') {
|
|
10624
|
+
// isArrayLike
|
|
10625
|
+
return mix.map(function (str) {
|
|
10626
|
+
return ValueExtractor.interpolateAny(str, values, options);
|
|
10627
|
+
});
|
|
10628
|
+
}
|
|
10629
|
+
return mix;
|
|
10630
|
+
};
|
|
10631
|
+
ValueExtractor.interpolateStr = function (str, values) {
|
|
10632
|
+
return str.replace(/\{\{(\w+)\}\}/g, function (full, prop) {
|
|
10633
|
+
var val = values[prop];
|
|
10634
|
+
if (val == null) {
|
|
10635
|
+
console.warn('Extracted property expected: ', prop, values);
|
|
10636
|
+
return '';
|
|
10637
|
+
}
|
|
10638
|
+
return val;
|
|
10639
|
+
});
|
|
10640
|
+
};
|
|
10641
|
+
return ValueExtractor;
|
|
10642
|
+
}());
|
|
10643
|
+
exports.ValueExtractor = ValueExtractor;
|
|
10635
10644
|
;
|
|
10636
10645
|
|
|
10637
10646
|
function __isObj(x) {
|
|
@@ -10659,17 +10668,17 @@ var _src_util_serialize;
|
|
|
10659
10668
|
var exports = _src_util_serialize != null ? _src_util_serialize : {};
|
|
10660
10669
|
var module = { exports: exports };
|
|
10661
10670
|
|
|
10662
|
-
"use strict";
|
|
10663
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10664
|
-
exports.serialize_error = void 0;
|
|
10665
|
-
function serialize_error(err) {
|
|
10666
|
-
var _a;
|
|
10667
|
-
return {
|
|
10668
|
-
message: (_a = err.message) !== null && _a !== void 0 ? _a : String(err),
|
|
10669
|
-
stack: err.stack
|
|
10670
|
-
};
|
|
10671
|
-
}
|
|
10672
|
-
exports.serialize_error = serialize_error;
|
|
10671
|
+
"use strict";
|
|
10672
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10673
|
+
exports.serialize_error = void 0;
|
|
10674
|
+
function serialize_error(err) {
|
|
10675
|
+
var _a;
|
|
10676
|
+
return {
|
|
10677
|
+
message: (_a = err.message) !== null && _a !== void 0 ? _a : String(err),
|
|
10678
|
+
stack: err.stack
|
|
10679
|
+
};
|
|
10680
|
+
}
|
|
10681
|
+
exports.serialize_error = serialize_error;
|
|
10673
10682
|
;
|
|
10674
10683
|
|
|
10675
10684
|
function __isObj(x) {
|
|
@@ -10697,135 +10706,135 @@ var _src_CommunicationChannel;
|
|
|
10697
10706
|
var exports = _src_CommunicationChannel != null ? _src_CommunicationChannel : {};
|
|
10698
10707
|
var module = { exports: exports };
|
|
10699
10708
|
|
|
10700
|
-
"use strict";
|
|
10701
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10702
|
-
exports.CommunicationChannel = void 0;
|
|
10703
|
-
var atma_utils_1 = require("atma-utils");
|
|
10704
|
-
var serialize_1 = _src_util_serialize;
|
|
10705
|
-
var CommunicationChannel = /** @class */ (function () {
|
|
10706
|
-
function CommunicationChannel(child, timeoutMs) {
|
|
10707
|
-
var _this = this;
|
|
10708
|
-
this.child = child;
|
|
10709
|
-
this.timeoutMs = timeoutMs;
|
|
10710
|
-
this.awaiters = Object.create(null);
|
|
10711
|
-
child.on('message', function (resp) {
|
|
10712
|
-
if (resp.id == null || resp.id in _this.awaiters === false) {
|
|
10713
|
-
return;
|
|
10714
|
-
}
|
|
10715
|
-
var awaiter = _this.awaiters[resp.id];
|
|
10716
|
-
delete _this.awaiters[resp.id];
|
|
10717
|
-
if (resp.error) {
|
|
10718
|
-
awaiter.promise.reject(resp.error);
|
|
10719
|
-
return;
|
|
10720
|
-
}
|
|
10721
|
-
awaiter.promise.resolve(resp.data);
|
|
10722
|
-
});
|
|
10723
|
-
}
|
|
10724
|
-
CommunicationChannel.ipc = function (handlers) {
|
|
10725
|
-
process.on('message', function (message) {
|
|
10726
|
-
var id = message.id, method = message.method, args = message.args;
|
|
10727
|
-
var handler = (0, atma_utils_1.obj_getProperty)(handlers, method);
|
|
10728
|
-
if (typeof handler !== 'function') {
|
|
10729
|
-
process.send({
|
|
10730
|
-
id: id,
|
|
10731
|
-
error: (0, serialize_1.serialize_error)(new Error("".concat(method, " not defined")))
|
|
10732
|
-
});
|
|
10733
|
-
return;
|
|
10734
|
-
}
|
|
10735
|
-
try {
|
|
10736
|
-
var result = handler.apply(null, args);
|
|
10737
|
-
if (result == null) {
|
|
10738
|
-
process.send({
|
|
10739
|
-
id: id,
|
|
10740
|
-
data: null
|
|
10741
|
-
});
|
|
10742
|
-
return;
|
|
10743
|
-
}
|
|
10744
|
-
if (typeof result.then === 'function') {
|
|
10745
|
-
result.then(function (data) {
|
|
10746
|
-
process.send({
|
|
10747
|
-
id: id,
|
|
10748
|
-
data: data
|
|
10749
|
-
});
|
|
10750
|
-
}, function (error) {
|
|
10751
|
-
process.send({
|
|
10752
|
-
id: id,
|
|
10753
|
-
error: (0, serialize_1.serialize_error)(error),
|
|
10754
|
-
});
|
|
10755
|
-
});
|
|
10756
|
-
return;
|
|
10757
|
-
}
|
|
10758
|
-
process.send({
|
|
10759
|
-
id: id,
|
|
10760
|
-
data: result
|
|
10761
|
-
});
|
|
10762
|
-
}
|
|
10763
|
-
catch (error) {
|
|
10764
|
-
process.send({
|
|
10765
|
-
id: id,
|
|
10766
|
-
error: (0, serialize_1.serialize_error)(error),
|
|
10767
|
-
});
|
|
10768
|
-
return;
|
|
10769
|
-
}
|
|
10770
|
-
});
|
|
10771
|
-
setTimeout(function () { return console.log('IPC Listening'); }, 10);
|
|
10772
|
-
};
|
|
10773
|
-
CommunicationChannel.prototype.call = function (method) {
|
|
10774
|
-
var _this = this;
|
|
10775
|
-
var args = [];
|
|
10776
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
10777
|
-
args[_i - 1] = arguments[_i];
|
|
10778
|
-
}
|
|
10779
|
-
var promise = new atma_utils_1.class_Dfr;
|
|
10780
|
-
var id = (Math.round(Math.random() * Math.pow(10, 10))) + '' + Date.now();
|
|
10781
|
-
this.awaiters[id] = {
|
|
10782
|
-
timestamp: Date.now(),
|
|
10783
|
-
promise: promise
|
|
10784
|
-
};
|
|
10785
|
-
this.child.send({
|
|
10786
|
-
id: id,
|
|
10787
|
-
method: method,
|
|
10788
|
-
args: args
|
|
10789
|
-
});
|
|
10790
|
-
if (this.timeoutMs) {
|
|
10791
|
-
setTimeout(function () { return _this.checkTimeout(); }, this.timeoutMs);
|
|
10792
|
-
}
|
|
10793
|
-
return promise;
|
|
10794
|
-
};
|
|
10795
|
-
CommunicationChannel.prototype.checkTimeout = function () {
|
|
10796
|
-
var _this = this;
|
|
10797
|
-
var now = Date.now();
|
|
10798
|
-
var keys = [];
|
|
10799
|
-
for (var key in this.awaiters) {
|
|
10800
|
-
var bin = this.awaiters[key];
|
|
10801
|
-
var ms = now - bin.timestamp;
|
|
10802
|
-
if (ms >= this.timeoutMs) {
|
|
10803
|
-
try {
|
|
10804
|
-
bin.promise.reject(new Error('Timeouted'));
|
|
10805
|
-
}
|
|
10806
|
-
catch (error) { }
|
|
10807
|
-
keys.push(key);
|
|
10808
|
-
}
|
|
10809
|
-
}
|
|
10810
|
-
keys.forEach(function (key) { return delete _this.awaiters[key]; });
|
|
10811
|
-
};
|
|
10812
|
-
CommunicationChannel.prototype.onError = function (error) {
|
|
10813
|
-
var obj = Object.create(this.awaiters);
|
|
10814
|
-
this.awaiters = {};
|
|
10815
|
-
for (var key in obj) {
|
|
10816
|
-
var bin = obj[key];
|
|
10817
|
-
try {
|
|
10818
|
-
bin.promise.reject(error);
|
|
10819
|
-
}
|
|
10820
|
-
catch (error) { }
|
|
10821
|
-
}
|
|
10822
|
-
};
|
|
10823
|
-
CommunicationChannel.prototype.onStdError = function (str) {
|
|
10824
|
-
this.onError(new Error(str));
|
|
10825
|
-
};
|
|
10826
|
-
return CommunicationChannel;
|
|
10827
|
-
}());
|
|
10828
|
-
exports.CommunicationChannel = CommunicationChannel;
|
|
10709
|
+
"use strict";
|
|
10710
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10711
|
+
exports.CommunicationChannel = void 0;
|
|
10712
|
+
var atma_utils_1 = require("atma-utils");
|
|
10713
|
+
var serialize_1 = _src_util_serialize;
|
|
10714
|
+
var CommunicationChannel = /** @class */ (function () {
|
|
10715
|
+
function CommunicationChannel(child, timeoutMs) {
|
|
10716
|
+
var _this = this;
|
|
10717
|
+
this.child = child;
|
|
10718
|
+
this.timeoutMs = timeoutMs;
|
|
10719
|
+
this.awaiters = Object.create(null);
|
|
10720
|
+
child.on('message', function (resp) {
|
|
10721
|
+
if (resp.id == null || resp.id in _this.awaiters === false) {
|
|
10722
|
+
return;
|
|
10723
|
+
}
|
|
10724
|
+
var awaiter = _this.awaiters[resp.id];
|
|
10725
|
+
delete _this.awaiters[resp.id];
|
|
10726
|
+
if (resp.error) {
|
|
10727
|
+
awaiter.promise.reject(resp.error);
|
|
10728
|
+
return;
|
|
10729
|
+
}
|
|
10730
|
+
awaiter.promise.resolve(resp.data);
|
|
10731
|
+
});
|
|
10732
|
+
}
|
|
10733
|
+
CommunicationChannel.ipc = function (handlers) {
|
|
10734
|
+
process.on('message', function (message) {
|
|
10735
|
+
var id = message.id, method = message.method, args = message.args;
|
|
10736
|
+
var handler = (0, atma_utils_1.obj_getProperty)(handlers, method);
|
|
10737
|
+
if (typeof handler !== 'function') {
|
|
10738
|
+
process.send({
|
|
10739
|
+
id: id,
|
|
10740
|
+
error: (0, serialize_1.serialize_error)(new Error("".concat(method, " not defined")))
|
|
10741
|
+
});
|
|
10742
|
+
return;
|
|
10743
|
+
}
|
|
10744
|
+
try {
|
|
10745
|
+
var result = handler.apply(null, args);
|
|
10746
|
+
if (result == null) {
|
|
10747
|
+
process.send({
|
|
10748
|
+
id: id,
|
|
10749
|
+
data: null
|
|
10750
|
+
});
|
|
10751
|
+
return;
|
|
10752
|
+
}
|
|
10753
|
+
if (typeof result.then === 'function') {
|
|
10754
|
+
result.then(function (data) {
|
|
10755
|
+
process.send({
|
|
10756
|
+
id: id,
|
|
10757
|
+
data: data
|
|
10758
|
+
});
|
|
10759
|
+
}, function (error) {
|
|
10760
|
+
process.send({
|
|
10761
|
+
id: id,
|
|
10762
|
+
error: (0, serialize_1.serialize_error)(error),
|
|
10763
|
+
});
|
|
10764
|
+
});
|
|
10765
|
+
return;
|
|
10766
|
+
}
|
|
10767
|
+
process.send({
|
|
10768
|
+
id: id,
|
|
10769
|
+
data: result
|
|
10770
|
+
});
|
|
10771
|
+
}
|
|
10772
|
+
catch (error) {
|
|
10773
|
+
process.send({
|
|
10774
|
+
id: id,
|
|
10775
|
+
error: (0, serialize_1.serialize_error)(error),
|
|
10776
|
+
});
|
|
10777
|
+
return;
|
|
10778
|
+
}
|
|
10779
|
+
});
|
|
10780
|
+
setTimeout(function () { return console.log('IPC Listening'); }, 10);
|
|
10781
|
+
};
|
|
10782
|
+
CommunicationChannel.prototype.call = function (method) {
|
|
10783
|
+
var _this = this;
|
|
10784
|
+
var args = [];
|
|
10785
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
10786
|
+
args[_i - 1] = arguments[_i];
|
|
10787
|
+
}
|
|
10788
|
+
var promise = new atma_utils_1.class_Dfr;
|
|
10789
|
+
var id = (Math.round(Math.random() * Math.pow(10, 10))) + '' + Date.now();
|
|
10790
|
+
this.awaiters[id] = {
|
|
10791
|
+
timestamp: Date.now(),
|
|
10792
|
+
promise: promise
|
|
10793
|
+
};
|
|
10794
|
+
this.child.send({
|
|
10795
|
+
id: id,
|
|
10796
|
+
method: method,
|
|
10797
|
+
args: args
|
|
10798
|
+
});
|
|
10799
|
+
if (this.timeoutMs) {
|
|
10800
|
+
setTimeout(function () { return _this.checkTimeout(); }, this.timeoutMs);
|
|
10801
|
+
}
|
|
10802
|
+
return promise;
|
|
10803
|
+
};
|
|
10804
|
+
CommunicationChannel.prototype.checkTimeout = function () {
|
|
10805
|
+
var _this = this;
|
|
10806
|
+
var now = Date.now();
|
|
10807
|
+
var keys = [];
|
|
10808
|
+
for (var key in this.awaiters) {
|
|
10809
|
+
var bin = this.awaiters[key];
|
|
10810
|
+
var ms = now - bin.timestamp;
|
|
10811
|
+
if (ms >= this.timeoutMs) {
|
|
10812
|
+
try {
|
|
10813
|
+
bin.promise.reject(new Error('Timeouted'));
|
|
10814
|
+
}
|
|
10815
|
+
catch (error) { }
|
|
10816
|
+
keys.push(key);
|
|
10817
|
+
}
|
|
10818
|
+
}
|
|
10819
|
+
keys.forEach(function (key) { return delete _this.awaiters[key]; });
|
|
10820
|
+
};
|
|
10821
|
+
CommunicationChannel.prototype.onError = function (error) {
|
|
10822
|
+
var obj = Object.create(this.awaiters);
|
|
10823
|
+
this.awaiters = {};
|
|
10824
|
+
for (var key in obj) {
|
|
10825
|
+
var bin = obj[key];
|
|
10826
|
+
try {
|
|
10827
|
+
bin.promise.reject(error);
|
|
10828
|
+
}
|
|
10829
|
+
catch (error) { }
|
|
10830
|
+
}
|
|
10831
|
+
};
|
|
10832
|
+
CommunicationChannel.prototype.onStdError = function (str) {
|
|
10833
|
+
this.onError(new Error(str));
|
|
10834
|
+
};
|
|
10835
|
+
return CommunicationChannel;
|
|
10836
|
+
}());
|
|
10837
|
+
exports.CommunicationChannel = CommunicationChannel;
|
|
10829
10838
|
;
|
|
10830
10839
|
|
|
10831
10840
|
function __isObj(x) {
|
|
@@ -10853,30 +10862,30 @@ var _src_util_events;
|
|
|
10853
10862
|
var exports = _src_util_events != null ? _src_util_events : {};
|
|
10854
10863
|
var module = { exports: exports };
|
|
10855
10864
|
|
|
10856
|
-
"use strict";
|
|
10857
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10858
|
-
exports.events_someOnce = void 0;
|
|
10859
|
-
function events_someOnce(emitter, events) {
|
|
10860
|
-
var listeners = {};
|
|
10861
|
-
for (var event in events) {
|
|
10862
|
-
emitter.on(event, delegate(emitter, listeners, event, events[event]));
|
|
10863
|
-
}
|
|
10864
|
-
}
|
|
10865
|
-
exports.events_someOnce = events_someOnce;
|
|
10866
|
-
function delegate(emitter, listeners, event, cb) {
|
|
10867
|
-
function fn() {
|
|
10868
|
-
var args = [];
|
|
10869
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
10870
|
-
args[_i] = arguments[_i];
|
|
10871
|
-
}
|
|
10872
|
-
for (var event_1 in listeners) {
|
|
10873
|
-
emitter.off(event_1, listeners[event_1]);
|
|
10874
|
-
}
|
|
10875
|
-
cb === null || cb === void 0 ? void 0 : cb.apply(void 0, args);
|
|
10876
|
-
}
|
|
10877
|
-
listeners[event] = fn;
|
|
10878
|
-
return fn;
|
|
10879
|
-
}
|
|
10865
|
+
"use strict";
|
|
10866
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10867
|
+
exports.events_someOnce = void 0;
|
|
10868
|
+
function events_someOnce(emitter, events) {
|
|
10869
|
+
var listeners = {};
|
|
10870
|
+
for (var event in events) {
|
|
10871
|
+
emitter.on(event, delegate(emitter, listeners, event, events[event]));
|
|
10872
|
+
}
|
|
10873
|
+
}
|
|
10874
|
+
exports.events_someOnce = events_someOnce;
|
|
10875
|
+
function delegate(emitter, listeners, event, cb) {
|
|
10876
|
+
function fn() {
|
|
10877
|
+
var args = [];
|
|
10878
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
10879
|
+
args[_i] = arguments[_i];
|
|
10880
|
+
}
|
|
10881
|
+
for (var event_1 in listeners) {
|
|
10882
|
+
emitter.off(event_1, listeners[event_1]);
|
|
10883
|
+
}
|
|
10884
|
+
cb === null || cb === void 0 ? void 0 : cb.apply(void 0, args);
|
|
10885
|
+
}
|
|
10886
|
+
listeners[event] = fn;
|
|
10887
|
+
return fn;
|
|
10888
|
+
}
|
|
10880
10889
|
;
|
|
10881
10890
|
|
|
10882
10891
|
function __isObj(x) {
|
|
@@ -10904,33 +10913,33 @@ var _src_util_ShellParamsUtil;
|
|
|
10904
10913
|
var exports = _src_util_ShellParamsUtil != null ? _src_util_ShellParamsUtil : {};
|
|
10905
10914
|
var module = { exports: exports };
|
|
10906
10915
|
|
|
10907
|
-
"use strict";
|
|
10908
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10909
|
-
exports.ShellParamsUtil = void 0;
|
|
10910
|
-
var ShellParamsUtil;
|
|
10911
|
-
(function (ShellParamsUtil) {
|
|
10912
|
-
function normalize(params) {
|
|
10913
|
-
var _a, _b;
|
|
10914
|
-
if (params.shell == null && !params.fork) {
|
|
10915
|
-
params.shell = DEFAULT.shell;
|
|
10916
|
-
}
|
|
10917
|
-
if (params.command != null) {
|
|
10918
|
-
params.commands = [params.command];
|
|
10919
|
-
}
|
|
10920
|
-
if (params.commands == null) {
|
|
10921
|
-
throw new Error("shellbee: Command(s) are not defined");
|
|
10922
|
-
}
|
|
10923
|
-
(_a = params.parallel) !== null && _a !== void 0 ? _a : (params.parallel = false);
|
|
10924
|
-
(_b = params.restartOnErrorExit) !== null && _b !== void 0 ? _b : (params.restartOnErrorExit = false);
|
|
10925
|
-
return params;
|
|
10926
|
-
}
|
|
10927
|
-
ShellParamsUtil.normalize = normalize;
|
|
10928
|
-
})(ShellParamsUtil = exports.ShellParamsUtil || (exports.ShellParamsUtil = {}));
|
|
10929
|
-
var DEFAULT = {
|
|
10930
|
-
shell: global.process.platform === 'win32'
|
|
10931
|
-
? ['cmd.exe', '/C']
|
|
10932
|
-
: null
|
|
10933
|
-
};
|
|
10916
|
+
"use strict";
|
|
10917
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10918
|
+
exports.ShellParamsUtil = void 0;
|
|
10919
|
+
var ShellParamsUtil;
|
|
10920
|
+
(function (ShellParamsUtil) {
|
|
10921
|
+
function normalize(params) {
|
|
10922
|
+
var _a, _b;
|
|
10923
|
+
if (params.shell == null && !params.fork) {
|
|
10924
|
+
params.shell = DEFAULT.shell;
|
|
10925
|
+
}
|
|
10926
|
+
if (params.command != null) {
|
|
10927
|
+
params.commands = [params.command];
|
|
10928
|
+
}
|
|
10929
|
+
if (params.commands == null) {
|
|
10930
|
+
throw new Error("shellbee: Command(s) are not defined");
|
|
10931
|
+
}
|
|
10932
|
+
(_a = params.parallel) !== null && _a !== void 0 ? _a : (params.parallel = false);
|
|
10933
|
+
(_b = params.restartOnErrorExit) !== null && _b !== void 0 ? _b : (params.restartOnErrorExit = false);
|
|
10934
|
+
return params;
|
|
10935
|
+
}
|
|
10936
|
+
ShellParamsUtil.normalize = normalize;
|
|
10937
|
+
})(ShellParamsUtil = exports.ShellParamsUtil || (exports.ShellParamsUtil = {}));
|
|
10938
|
+
var DEFAULT = {
|
|
10939
|
+
shell: global.process.platform === 'win32'
|
|
10940
|
+
? ['cmd.exe', '/C']
|
|
10941
|
+
: null
|
|
10942
|
+
};
|
|
10934
10943
|
;
|
|
10935
10944
|
|
|
10936
10945
|
function __isObj(x) {
|
|
@@ -10958,46 +10967,46 @@ var _src_util_ShellErrorExitsHandler;
|
|
|
10958
10967
|
var exports = _src_util_ShellErrorExitsHandler != null ? _src_util_ShellErrorExitsHandler : {};
|
|
10959
10968
|
var module = { exports: exports };
|
|
10960
10969
|
|
|
10961
|
-
"use strict";
|
|
10962
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10963
|
-
exports.ShellErrorExitsHandler = void 0;
|
|
10964
|
-
var ShellErrorExitsHandler = /** @class */ (function () {
|
|
10965
|
-
function ShellErrorExitsHandler(params) {
|
|
10966
|
-
var _a, _b, _c;
|
|
10967
|
-
this._active = false;
|
|
10968
|
-
this.options = {
|
|
10969
|
-
delayMs: 200,
|
|
10970
|
-
maxRestartCount: 10,
|
|
10971
|
-
maxRestartTimespanMs: 30 * 1000,
|
|
10972
|
-
};
|
|
10973
|
-
this._params = params;
|
|
10974
|
-
this._errors = [];
|
|
10975
|
-
this._active = params.restartOnErrorExit != null && params.restartOnErrorExit !== false;
|
|
10976
|
-
if (typeof params.restartOnErrorExit !== 'boolean') {
|
|
10977
|
-
var opts = params.restartOnErrorExit;
|
|
10978
|
-
this.options.delayMs = (_a = opts.delayMs) !== null && _a !== void 0 ? _a : this.options.delayMs;
|
|
10979
|
-
this.options.maxRestartCount = (_b = opts.maxRestartCount) !== null && _b !== void 0 ? _b : this.options.maxRestartCount;
|
|
10980
|
-
this.options.maxRestartTimespanMs = (_c = opts.maxRestartTimespanMs) !== null && _c !== void 0 ? _c : this.options.maxRestartTimespanMs;
|
|
10981
|
-
}
|
|
10982
|
-
}
|
|
10983
|
-
ShellErrorExitsHandler.prototype.delay = function (cb) {
|
|
10984
|
-
this._errors.push({ time: Date.now() });
|
|
10985
|
-
setTimeout(function () { return cb(); }, this.options.delayMs);
|
|
10986
|
-
};
|
|
10987
|
-
ShellErrorExitsHandler.prototype.isActive = function () {
|
|
10988
|
-
if (this._active !== true) {
|
|
10989
|
-
return false;
|
|
10990
|
-
}
|
|
10991
|
-
var fromTimePoint = Date.now() - this.options.maxRestartTimespanMs;
|
|
10992
|
-
var errors = this._errors.filter(function (x) { return x.time > fromTimePoint; });
|
|
10993
|
-
if (errors.length < this.options.maxRestartCount) {
|
|
10994
|
-
return true;
|
|
10995
|
-
}
|
|
10996
|
-
return false;
|
|
10997
|
-
};
|
|
10998
|
-
return ShellErrorExitsHandler;
|
|
10999
|
-
}());
|
|
11000
|
-
exports.ShellErrorExitsHandler = ShellErrorExitsHandler;
|
|
10970
|
+
"use strict";
|
|
10971
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10972
|
+
exports.ShellErrorExitsHandler = void 0;
|
|
10973
|
+
var ShellErrorExitsHandler = /** @class */ (function () {
|
|
10974
|
+
function ShellErrorExitsHandler(params) {
|
|
10975
|
+
var _a, _b, _c;
|
|
10976
|
+
this._active = false;
|
|
10977
|
+
this.options = {
|
|
10978
|
+
delayMs: 200,
|
|
10979
|
+
maxRestartCount: 10,
|
|
10980
|
+
maxRestartTimespanMs: 30 * 1000,
|
|
10981
|
+
};
|
|
10982
|
+
this._params = params;
|
|
10983
|
+
this._errors = [];
|
|
10984
|
+
this._active = params.restartOnErrorExit != null && params.restartOnErrorExit !== false;
|
|
10985
|
+
if (typeof params.restartOnErrorExit !== 'boolean') {
|
|
10986
|
+
var opts = params.restartOnErrorExit;
|
|
10987
|
+
this.options.delayMs = (_a = opts.delayMs) !== null && _a !== void 0 ? _a : this.options.delayMs;
|
|
10988
|
+
this.options.maxRestartCount = (_b = opts.maxRestartCount) !== null && _b !== void 0 ? _b : this.options.maxRestartCount;
|
|
10989
|
+
this.options.maxRestartTimespanMs = (_c = opts.maxRestartTimespanMs) !== null && _c !== void 0 ? _c : this.options.maxRestartTimespanMs;
|
|
10990
|
+
}
|
|
10991
|
+
}
|
|
10992
|
+
ShellErrorExitsHandler.prototype.delay = function (cb) {
|
|
10993
|
+
this._errors.push({ time: Date.now() });
|
|
10994
|
+
setTimeout(function () { return cb(); }, this.options.delayMs);
|
|
10995
|
+
};
|
|
10996
|
+
ShellErrorExitsHandler.prototype.isActive = function () {
|
|
10997
|
+
if (this._active !== true) {
|
|
10998
|
+
return false;
|
|
10999
|
+
}
|
|
11000
|
+
var fromTimePoint = Date.now() - this.options.maxRestartTimespanMs;
|
|
11001
|
+
var errors = this._errors.filter(function (x) { return x.time > fromTimePoint; });
|
|
11002
|
+
if (errors.length < this.options.maxRestartCount) {
|
|
11003
|
+
return true;
|
|
11004
|
+
}
|
|
11005
|
+
return false;
|
|
11006
|
+
};
|
|
11007
|
+
return ShellErrorExitsHandler;
|
|
11008
|
+
}());
|
|
11009
|
+
exports.ShellErrorExitsHandler = ShellErrorExitsHandler;
|
|
11001
11010
|
;
|
|
11002
11011
|
|
|
11003
11012
|
function __isObj(x) {
|
|
@@ -11025,119 +11034,119 @@ var _src_util_ShellStalledOutputHandler;
|
|
|
11025
11034
|
var exports = _src_util_ShellStalledOutputHandler != null ? _src_util_ShellStalledOutputHandler : {};
|
|
11026
11035
|
var module = { exports: exports };
|
|
11027
11036
|
|
|
11028
|
-
"use strict";
|
|
11029
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
11030
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
11031
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
11032
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
11033
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
11034
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
11035
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
11036
|
-
});
|
|
11037
|
-
};
|
|
11038
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11039
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
11040
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
11041
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
11042
|
-
function step(op) {
|
|
11043
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
11044
|
-
while (_) try {
|
|
11045
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
11046
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
11047
|
-
switch (op[0]) {
|
|
11048
|
-
case 0: case 1: t = op; break;
|
|
11049
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
11050
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
11051
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
11052
|
-
default:
|
|
11053
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
11054
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
11055
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
11056
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
11057
|
-
if (t[2]) _.ops.pop();
|
|
11058
|
-
_.trys.pop(); continue;
|
|
11059
|
-
}
|
|
11060
|
-
op = body.call(thisArg, _);
|
|
11061
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
11062
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
11063
|
-
}
|
|
11064
|
-
};
|
|
11065
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11066
|
-
exports.ShellStalledOutputHandler = void 0;
|
|
11067
|
-
var ShellStalledOutputHandler = /** @class */ (function () {
|
|
11068
|
-
function ShellStalledOutputHandler(params, shell) {
|
|
11069
|
-
this.params = params;
|
|
11070
|
-
this.shell = shell;
|
|
11071
|
-
}
|
|
11072
|
-
ShellStalledOutputHandler.prototype.init = function () {
|
|
11073
|
-
var _this = this;
|
|
11074
|
-
var _a;
|
|
11075
|
-
var _b = this, shell = _b.shell, params = _b.params;
|
|
11076
|
-
this._ms = (_a = params.restartOnStalledOutput) === null || _a === void 0 ? void 0 : _a.emptyOutputInterval;
|
|
11077
|
-
if (typeof this._ms !== 'number' || this._ms === 0) {
|
|
11078
|
-
return;
|
|
11079
|
-
}
|
|
11080
|
-
shell
|
|
11081
|
-
.on('process_start', function (data) { return _this.onProcessStarted(data); })
|
|
11082
|
-
.on('process_exit', function (data) { return _this.onProcessExit(data); })
|
|
11083
|
-
.on('process_stderr', function (data) { return _this.onProcessStd('stderr', data); })
|
|
11084
|
-
.on('process_stdout', function (data) { return _this.onProcessStd('stdout', data); });
|
|
11085
|
-
};
|
|
11086
|
-
ShellStalledOutputHandler.prototype.onProcessStarted = function (data) {
|
|
11087
|
-
this._lastOutput = Date.now();
|
|
11088
|
-
this.stop();
|
|
11089
|
-
this.defer(this._ms);
|
|
11090
|
-
};
|
|
11091
|
-
ShellStalledOutputHandler.prototype.onProcessExit = function (data) {
|
|
11092
|
-
this.stop();
|
|
11093
|
-
};
|
|
11094
|
-
ShellStalledOutputHandler.prototype.onProcessStd = function (output, data) {
|
|
11095
|
-
this._lastOutput = Date.now();
|
|
11096
|
-
};
|
|
11097
|
-
ShellStalledOutputHandler.prototype.stop = function () {
|
|
11098
|
-
clearTimeout(this._timeout);
|
|
11099
|
-
};
|
|
11100
|
-
ShellStalledOutputHandler.prototype.defer = function (ms) {
|
|
11101
|
-
var _this = this;
|
|
11102
|
-
this._timeout = setTimeout(function () { return _this.onTimer(); }, ms);
|
|
11103
|
-
};
|
|
11104
|
-
ShellStalledOutputHandler.prototype.onTimer = function () {
|
|
11105
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
11106
|
-
var ms;
|
|
11107
|
-
return __generator(this, function (_a) {
|
|
11108
|
-
switch (_a.label) {
|
|
11109
|
-
case 0:
|
|
11110
|
-
ms = Date.now() - this._lastOutput;
|
|
11111
|
-
if (!(ms >= this._ms)) return [3 /*break*/, 2];
|
|
11112
|
-
return [4 /*yield*/, this.restart()];
|
|
11113
|
-
case 1:
|
|
11114
|
-
_a.sent();
|
|
11115
|
-
return [2 /*return*/];
|
|
11116
|
-
case 2:
|
|
11117
|
-
// otherwise check again after (TIMEOUT_MS - LAST_OUTPUT_MS)
|
|
11118
|
-
this.defer(this._ms - ms);
|
|
11119
|
-
return [2 /*return*/];
|
|
11120
|
-
}
|
|
11121
|
-
});
|
|
11122
|
-
});
|
|
11123
|
-
};
|
|
11124
|
-
ShellStalledOutputHandler.prototype.restart = function () {
|
|
11125
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
11126
|
-
return __generator(this, function (_a) {
|
|
11127
|
-
switch (_a.label) {
|
|
11128
|
-
case 0:
|
|
11129
|
-
console.log("Restarting the process, as there was not output for ".concat(this._ms, "ms"));
|
|
11130
|
-
return [4 /*yield*/, this.shell.restart()];
|
|
11131
|
-
case 1:
|
|
11132
|
-
_a.sent();
|
|
11133
|
-
return [2 /*return*/];
|
|
11134
|
-
}
|
|
11135
|
-
});
|
|
11136
|
-
});
|
|
11137
|
-
};
|
|
11138
|
-
return ShellStalledOutputHandler;
|
|
11139
|
-
}());
|
|
11140
|
-
exports.ShellStalledOutputHandler = ShellStalledOutputHandler;
|
|
11037
|
+
"use strict";
|
|
11038
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
11039
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
11040
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
11041
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
11042
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
11043
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
11044
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
11045
|
+
});
|
|
11046
|
+
};
|
|
11047
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11048
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
11049
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
11050
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
11051
|
+
function step(op) {
|
|
11052
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
11053
|
+
while (_) try {
|
|
11054
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
11055
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
11056
|
+
switch (op[0]) {
|
|
11057
|
+
case 0: case 1: t = op; break;
|
|
11058
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
11059
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
11060
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
11061
|
+
default:
|
|
11062
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
11063
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
11064
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
11065
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
11066
|
+
if (t[2]) _.ops.pop();
|
|
11067
|
+
_.trys.pop(); continue;
|
|
11068
|
+
}
|
|
11069
|
+
op = body.call(thisArg, _);
|
|
11070
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
11071
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
11072
|
+
}
|
|
11073
|
+
};
|
|
11074
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11075
|
+
exports.ShellStalledOutputHandler = void 0;
|
|
11076
|
+
var ShellStalledOutputHandler = /** @class */ (function () {
|
|
11077
|
+
function ShellStalledOutputHandler(params, shell) {
|
|
11078
|
+
this.params = params;
|
|
11079
|
+
this.shell = shell;
|
|
11080
|
+
}
|
|
11081
|
+
ShellStalledOutputHandler.prototype.init = function () {
|
|
11082
|
+
var _this = this;
|
|
11083
|
+
var _a;
|
|
11084
|
+
var _b = this, shell = _b.shell, params = _b.params;
|
|
11085
|
+
this._ms = (_a = params.restartOnStalledOutput) === null || _a === void 0 ? void 0 : _a.emptyOutputInterval;
|
|
11086
|
+
if (typeof this._ms !== 'number' || this._ms === 0) {
|
|
11087
|
+
return;
|
|
11088
|
+
}
|
|
11089
|
+
shell
|
|
11090
|
+
.on('process_start', function (data) { return _this.onProcessStarted(data); })
|
|
11091
|
+
.on('process_exit', function (data) { return _this.onProcessExit(data); })
|
|
11092
|
+
.on('process_stderr', function (data) { return _this.onProcessStd('stderr', data); })
|
|
11093
|
+
.on('process_stdout', function (data) { return _this.onProcessStd('stdout', data); });
|
|
11094
|
+
};
|
|
11095
|
+
ShellStalledOutputHandler.prototype.onProcessStarted = function (data) {
|
|
11096
|
+
this._lastOutput = Date.now();
|
|
11097
|
+
this.stop();
|
|
11098
|
+
this.defer(this._ms);
|
|
11099
|
+
};
|
|
11100
|
+
ShellStalledOutputHandler.prototype.onProcessExit = function (data) {
|
|
11101
|
+
this.stop();
|
|
11102
|
+
};
|
|
11103
|
+
ShellStalledOutputHandler.prototype.onProcessStd = function (output, data) {
|
|
11104
|
+
this._lastOutput = Date.now();
|
|
11105
|
+
};
|
|
11106
|
+
ShellStalledOutputHandler.prototype.stop = function () {
|
|
11107
|
+
clearTimeout(this._timeout);
|
|
11108
|
+
};
|
|
11109
|
+
ShellStalledOutputHandler.prototype.defer = function (ms) {
|
|
11110
|
+
var _this = this;
|
|
11111
|
+
this._timeout = setTimeout(function () { return _this.onTimer(); }, ms);
|
|
11112
|
+
};
|
|
11113
|
+
ShellStalledOutputHandler.prototype.onTimer = function () {
|
|
11114
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
11115
|
+
var ms;
|
|
11116
|
+
return __generator(this, function (_a) {
|
|
11117
|
+
switch (_a.label) {
|
|
11118
|
+
case 0:
|
|
11119
|
+
ms = Date.now() - this._lastOutput;
|
|
11120
|
+
if (!(ms >= this._ms)) return [3 /*break*/, 2];
|
|
11121
|
+
return [4 /*yield*/, this.restart()];
|
|
11122
|
+
case 1:
|
|
11123
|
+
_a.sent();
|
|
11124
|
+
return [2 /*return*/];
|
|
11125
|
+
case 2:
|
|
11126
|
+
// otherwise check again after (TIMEOUT_MS - LAST_OUTPUT_MS)
|
|
11127
|
+
this.defer(this._ms - ms);
|
|
11128
|
+
return [2 /*return*/];
|
|
11129
|
+
}
|
|
11130
|
+
});
|
|
11131
|
+
});
|
|
11132
|
+
};
|
|
11133
|
+
ShellStalledOutputHandler.prototype.restart = function () {
|
|
11134
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
11135
|
+
return __generator(this, function (_a) {
|
|
11136
|
+
switch (_a.label) {
|
|
11137
|
+
case 0:
|
|
11138
|
+
console.log("Restarting the process, as there was not output for ".concat(this._ms, "ms"));
|
|
11139
|
+
return [4 /*yield*/, this.shell.restart()];
|
|
11140
|
+
case 1:
|
|
11141
|
+
_a.sent();
|
|
11142
|
+
return [2 /*return*/];
|
|
11143
|
+
}
|
|
11144
|
+
});
|
|
11145
|
+
});
|
|
11146
|
+
};
|
|
11147
|
+
return ShellStalledOutputHandler;
|
|
11148
|
+
}());
|
|
11149
|
+
exports.ShellStalledOutputHandler = ShellStalledOutputHandler;
|
|
11141
11150
|
;
|
|
11142
11151
|
|
|
11143
11152
|
function __isObj(x) {
|
|
@@ -11165,563 +11174,563 @@ var _src_Shell;
|
|
|
11165
11174
|
var exports = _src_Shell != null ? _src_Shell : {};
|
|
11166
11175
|
var module = { exports: exports };
|
|
11167
11176
|
|
|
11168
|
-
"use strict";
|
|
11169
|
-
var __extends = (this && this.__extends) || (function () {
|
|
11170
|
-
var extendStatics = function (d, b) {
|
|
11171
|
-
extendStatics = Object.setPrototypeOf ||
|
|
11172
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
11173
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
11174
|
-
return extendStatics(d, b);
|
|
11175
|
-
};
|
|
11176
|
-
return function (d, b) {
|
|
11177
|
-
if (typeof b !== "function" && b !== null)
|
|
11178
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
11179
|
-
extendStatics(d, b);
|
|
11180
|
-
function __() { this.constructor = d; }
|
|
11181
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
11182
|
-
};
|
|
11183
|
-
})();
|
|
11184
|
-
var __assign = (this && this.__assign) || function () {
|
|
11185
|
-
__assign = Object.assign || function(t) {
|
|
11186
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
11187
|
-
s = arguments[i];
|
|
11188
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
11189
|
-
t[p] = s[p];
|
|
11190
|
-
}
|
|
11191
|
-
return t;
|
|
11192
|
-
};
|
|
11193
|
-
return __assign.apply(this, arguments);
|
|
11194
|
-
};
|
|
11195
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
11196
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
11197
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
11198
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
11199
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
11200
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
11201
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
11202
|
-
});
|
|
11203
|
-
};
|
|
11204
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11205
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
11206
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
11207
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
11208
|
-
function step(op) {
|
|
11209
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
11210
|
-
while (_) try {
|
|
11211
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
11212
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
11213
|
-
switch (op[0]) {
|
|
11214
|
-
case 0: case 1: t = op; break;
|
|
11215
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
11216
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
11217
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
11218
|
-
default:
|
|
11219
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
11220
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
11221
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
11222
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
11223
|
-
if (t[2]) _.ops.pop();
|
|
11224
|
-
_.trys.pop(); continue;
|
|
11225
|
-
}
|
|
11226
|
-
op = body.call(thisArg, _);
|
|
11227
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
11228
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
11229
|
-
}
|
|
11230
|
-
};
|
|
11231
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
11232
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
11233
|
-
if (ar || !(i in from)) {
|
|
11234
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
11235
|
-
ar[i] = from[i];
|
|
11236
|
-
}
|
|
11237
|
-
}
|
|
11238
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
11239
|
-
};
|
|
11240
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11241
|
-
exports.ProcessResult = exports.Shell = void 0;
|
|
11242
|
-
var atma_utils_1 = require("atma-utils");
|
|
11243
|
-
var atma_io_1 = require("atma-io");
|
|
11244
|
-
var child_process = require("child_process");
|
|
11245
|
-
var command_1 = _src_util_command;
|
|
11246
|
-
var ValueExtractor_1 = _src_ValueExtractor;
|
|
11247
|
-
var CommunicationChannel_1 = _src_CommunicationChannel;
|
|
11248
|
-
var events_1 = _src_util_events;
|
|
11249
|
-
var treeKill = require("tree-kill");
|
|
11250
|
-
var ShellParamsUtil_1 = _src_util_ShellParamsUtil;
|
|
11251
|
-
var ShellErrorExitsHandler_1 = _src_util_ShellErrorExitsHandler;
|
|
11252
|
-
var ShellStalledOutputHandler_1 = _src_util_ShellStalledOutputHandler;
|
|
11253
|
-
var Shell = /** @class */ (function (_super) {
|
|
11254
|
-
__extends(Shell, _super);
|
|
11255
|
-
function Shell(params) {
|
|
11256
|
-
var _this = _super.call(this) || this;
|
|
11257
|
-
_this.children = [];
|
|
11258
|
-
_this.errors = [];
|
|
11259
|
-
_this.lastCode = 0;
|
|
11260
|
-
_this.results = [];
|
|
11261
|
-
_this.extracted = {};
|
|
11262
|
-
_this.state = ShellState.Initial;
|
|
11263
|
-
_this.promise = new atma_utils_1.class_Dfr();
|
|
11264
|
-
_this.std = [];
|
|
11265
|
-
_this.stderr = [];
|
|
11266
|
-
_this.stdout = [];
|
|
11267
|
-
_this.isBusy = false;
|
|
11268
|
-
_this.isReady = false;
|
|
11269
|
-
_this.params = ShellParamsUtil_1.ShellParamsUtil.normalize(params);
|
|
11270
|
-
_this.errorsHandler = new ShellErrorExitsHandler_1.ShellErrorExitsHandler(_this.params);
|
|
11271
|
-
_this.stalledOutputHandler = new ShellStalledOutputHandler_1.ShellStalledOutputHandler(_this.params, _this);
|
|
11272
|
-
_this.stalledOutputHandler.init();
|
|
11273
|
-
_this.commands = (0, command_1.command_parseAll)(params.commands, params);
|
|
11274
|
-
_this.commandsQueue = _this.commands.slice();
|
|
11275
|
-
_this.on('process_start', function () {
|
|
11276
|
-
_this.state = ShellState.Started;
|
|
11277
|
-
});
|
|
11278
|
-
return _this;
|
|
11279
|
-
}
|
|
11280
|
-
Shell.run = function (mix) {
|
|
11281
|
-
var params;
|
|
11282
|
-
if (typeof mix === 'string') {
|
|
11283
|
-
params = { command: mix };
|
|
11284
|
-
}
|
|
11285
|
-
else if (Array.isArray(mix)) {
|
|
11286
|
-
params = { commands: mix };
|
|
11287
|
-
}
|
|
11288
|
-
else {
|
|
11289
|
-
params = mix;
|
|
11290
|
-
}
|
|
11291
|
-
return new Shell(params).run();
|
|
11292
|
-
};
|
|
11293
|
-
/**
|
|
11294
|
-
* "Run" starts the command
|
|
11295
|
-
* @returns Promise, which is resolved after the executables are completed.
|
|
11296
|
-
*/
|
|
11297
|
-
Shell.prototype.run = function () {
|
|
11298
|
-
if (this.isBusy === false) {
|
|
11299
|
-
this.next();
|
|
11300
|
-
return this.promise;
|
|
11301
|
-
}
|
|
11302
|
-
return this.promise;
|
|
11303
|
-
};
|
|
11304
|
-
Shell.factory = function (config) {
|
|
11305
|
-
return {
|
|
11306
|
-
run: function (mix) {
|
|
11307
|
-
var params;
|
|
11308
|
-
if (typeof mix === 'string') {
|
|
11309
|
-
params = { command: mix };
|
|
11310
|
-
}
|
|
11311
|
-
else if (Array.isArray(mix)) {
|
|
11312
|
-
params = { commands: mix };
|
|
11313
|
-
}
|
|
11314
|
-
else {
|
|
11315
|
-
params = mix;
|
|
11316
|
-
}
|
|
11317
|
-
return Shell.run(__assign(__assign({}, config), params));
|
|
11318
|
-
}
|
|
11319
|
-
};
|
|
11320
|
-
};
|
|
11321
|
-
Shell.prototype.onStart = function (cb) {
|
|
11322
|
-
return this.on('process_start', cb);
|
|
11323
|
-
};
|
|
11324
|
-
Shell.prototype.onStdout = function (cb) {
|
|
11325
|
-
return this.on('process_stdout', cb);
|
|
11326
|
-
};
|
|
11327
|
-
Shell.prototype.onStderr = function (cb) {
|
|
11328
|
-
return this.on('process_stderr', cb);
|
|
11329
|
-
};
|
|
11330
|
-
Shell.prototype.onExit = function (cb) {
|
|
11331
|
-
return this.on('process_exit', cb);
|
|
11332
|
-
};
|
|
11333
|
-
/** When rgxReady is specified the event will be called */
|
|
11334
|
-
Shell.prototype.onReady = function (cb) {
|
|
11335
|
-
var _a, _b, _c, _d, _e, _f;
|
|
11336
|
-
var isAlreadyCompleted = this.isBusy === false && this.lastCode != null;
|
|
11337
|
-
var isReady = this.isReady;
|
|
11338
|
-
if (isReady || isAlreadyCompleted) {
|
|
11339
|
-
cb({ command: (_a = this.currentOptions) === null || _a === void 0 ? void 0 : _a.command });
|
|
11340
|
-
return;
|
|
11341
|
-
}
|
|
11342
|
-
if (!((_b = this.currentOptions) === null || _b === void 0 ? void 0 : _b.matchReady) && this.commandsQueue.some(function (x) { return x.matchReady; }) === false) {
|
|
11343
|
-
console.error('Ready Matcher Regex is not defined', (_d = (_c = this.currentOptions) === null || _c === void 0 ? void 0 : _c.command) !== null && _d !== void 0 ? _d : (_f = (_e = this.commands) === null || _e === void 0 ? void 0 : _e[0]) === null || _f === void 0 ? void 0 : _f.command);
|
|
11344
|
-
}
|
|
11345
|
-
return this.on('process_ready', cb);
|
|
11346
|
-
};
|
|
11347
|
-
Shell.prototype.onReadyAsync = function () {
|
|
11348
|
-
var _this = this;
|
|
11349
|
-
return new Promise(function (resolve) {
|
|
11350
|
-
_this.onReady(resolve);
|
|
11351
|
-
});
|
|
11352
|
-
};
|
|
11353
|
-
Shell.prototype.onComplete = function (cb) {
|
|
11354
|
-
var _this = this;
|
|
11355
|
-
this.promise.always(function () { return cb(_this); });
|
|
11356
|
-
return this;
|
|
11357
|
-
};
|
|
11358
|
-
Shell.prototype.onCompleteAsync = function () {
|
|
11359
|
-
var _this = this;
|
|
11360
|
-
return new Promise(function (resolve) {
|
|
11361
|
-
_this.onComplete(resolve);
|
|
11362
|
-
});
|
|
11363
|
-
};
|
|
11364
|
-
Shell.prototype.kill = function (mix) {
|
|
11365
|
-
var _this = this;
|
|
11366
|
-
var _a, _b, _c;
|
|
11367
|
-
var signal = 'SIGINT';
|
|
11368
|
-
var commandIdx = 0;
|
|
11369
|
-
var terminateAfterMs = null;
|
|
11370
|
-
if (mix != null) {
|
|
11371
|
-
signal = (_a = (typeof mix === 'object' ? mix.signal : mix)) !== null && _a !== void 0 ? _a : signal;
|
|
11372
|
-
if (typeof mix === 'object') {
|
|
11373
|
-
commandIdx = (_b = mix.commandIdx) !== null && _b !== void 0 ? _b : commandIdx;
|
|
11374
|
-
terminateAfterMs = (_c = mix.terminateAfter) !== null && _c !== void 0 ? _c : terminateAfterMs;
|
|
11375
|
-
}
|
|
11376
|
-
}
|
|
11377
|
-
return new Promise(function (resolve) {
|
|
11378
|
-
var isCompleted = _this.isBusy === false && _this.lastCode != null;
|
|
11379
|
-
if (isCompleted) {
|
|
11380
|
-
return resolve(null);
|
|
11381
|
-
}
|
|
11382
|
-
var options = _this.commands[commandIdx];
|
|
11383
|
-
var child = _this.children.find(function (x) { return x.options === options; });
|
|
11384
|
-
if (child == null) {
|
|
11385
|
-
return resolve(null);
|
|
11386
|
-
}
|
|
11387
|
-
var i = _this.children.indexOf(child);
|
|
11388
|
-
_this.children.splice(i, 1);
|
|
11389
|
-
var timeout;
|
|
11390
|
-
child.process.kill(signal);
|
|
11391
|
-
_this.once('process_exit', function () {
|
|
11392
|
-
if (timeout != null) {
|
|
11393
|
-
clearTimeout(timeout);
|
|
11394
|
-
}
|
|
11395
|
-
resolve(null);
|
|
11396
|
-
});
|
|
11397
|
-
if (terminateAfterMs != null) {
|
|
11398
|
-
timeout = setTimeout(function () {
|
|
11399
|
-
treeKill(child.process.pid);
|
|
11400
|
-
}, terminateAfterMs);
|
|
11401
|
-
}
|
|
11402
|
-
});
|
|
11403
|
-
};
|
|
11404
|
-
/** Uses tree-kill to terminate the tree */
|
|
11405
|
-
Shell.prototype.terminate = function () {
|
|
11406
|
-
var _this = this;
|
|
11407
|
-
return new Promise(function (resolve) {
|
|
11408
|
-
var child = _this.children.pop();
|
|
11409
|
-
if (child == null) {
|
|
11410
|
-
return resolve(null);
|
|
11411
|
-
}
|
|
11412
|
-
_this.once('process_exit', resolve);
|
|
11413
|
-
treeKill(child.process.pid);
|
|
11414
|
-
});
|
|
11415
|
-
};
|
|
11416
|
-
Shell.prototype.send = function (method) {
|
|
11417
|
-
var _this = this;
|
|
11418
|
-
var args = [];
|
|
11419
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
11420
|
-
args[_i - 1] = arguments[_i];
|
|
11421
|
-
}
|
|
11422
|
-
return new Promise(function (resolve, reject) {
|
|
11423
|
-
_this.waitForChannel().then(function (channel) {
|
|
11424
|
-
channel.call.apply(channel, __spreadArray([method], args, false)).then(resolve, reject);
|
|
11425
|
-
}, reject);
|
|
11426
|
-
});
|
|
11427
|
-
};
|
|
11428
|
-
Shell.prototype.restart = function (mix) {
|
|
11429
|
-
if (mix === void 0) { mix = 0; }
|
|
11430
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
11431
|
-
var options;
|
|
11432
|
-
return __generator(this, function (_a) {
|
|
11433
|
-
switch (_a.label) {
|
|
11434
|
-
case 0:
|
|
11435
|
-
if (typeof mix === 'number') {
|
|
11436
|
-
options = this.commands[mix];
|
|
11437
|
-
}
|
|
11438
|
-
else {
|
|
11439
|
-
options = this.commands.find(function (x) { return x.command === mix; });
|
|
11440
|
-
}
|
|
11441
|
-
if (options == null) {
|
|
11442
|
-
throw new Error("Options undefined for ".concat(mix));
|
|
11443
|
-
}
|
|
11444
|
-
this.commandsQueue.push(options);
|
|
11445
|
-
if (this.isBusy === false) {
|
|
11446
|
-
this.next();
|
|
11447
|
-
return [2 /*return*/];
|
|
11448
|
-
}
|
|
11449
|
-
// `next` will be called indirect (after the process exits)
|
|
11450
|
-
return [4 /*yield*/, this.kill({ terminateAfter: 10000 })];
|
|
11451
|
-
case 1:
|
|
11452
|
-
// `next` will be called indirect (after the process exits)
|
|
11453
|
-
_a.sent();
|
|
11454
|
-
return [2 /*return*/];
|
|
11455
|
-
}
|
|
11456
|
-
});
|
|
11457
|
-
});
|
|
11458
|
-
};
|
|
11459
|
-
Shell.prototype.waitForChannel = function () {
|
|
11460
|
-
var _this = this;
|
|
11461
|
-
if (this.currentOptions.ipc && this.isReady === false) {
|
|
11462
|
-
return new Promise(function (resolve, reject) {
|
|
11463
|
-
(0, events_1.events_someOnce)(_this, {
|
|
11464
|
-
'process_ready': function () {
|
|
11465
|
-
_this.waitForChannel().then(resolve, reject);
|
|
11466
|
-
},
|
|
11467
|
-
'exit': function () {
|
|
11468
|
-
reject('Process exited');
|
|
11469
|
-
}
|
|
11470
|
-
});
|
|
11471
|
-
});
|
|
11472
|
-
}
|
|
11473
|
-
return new Promise(function (resolve, reject) {
|
|
11474
|
-
if (_this.channel) {
|
|
11475
|
-
resolve(_this.channel);
|
|
11476
|
-
return;
|
|
11477
|
-
}
|
|
11478
|
-
(0, events_1.events_someOnce)(_this, {
|
|
11479
|
-
'channel_created': function () {
|
|
11480
|
-
resolve(_this.channel);
|
|
11481
|
-
},
|
|
11482
|
-
'exit': function () {
|
|
11483
|
-
reject('Process exited');
|
|
11484
|
-
}
|
|
11485
|
-
});
|
|
11486
|
-
});
|
|
11487
|
-
};
|
|
11488
|
-
Shell.prototype.next = function () {
|
|
11489
|
-
var _this = this;
|
|
11490
|
-
var _a;
|
|
11491
|
-
if (this.isBusy === false) {
|
|
11492
|
-
this.start = new Date();
|
|
11493
|
-
this.isBusy = true;
|
|
11494
|
-
this.isReady = false;
|
|
11495
|
-
}
|
|
11496
|
-
if (this.channel) {
|
|
11497
|
-
this.emit('channel_closed', {
|
|
11498
|
-
channel: this.channel
|
|
11499
|
-
});
|
|
11500
|
-
if (this.commandsQueue.length !== 0 || (this.lastCode === 1 && this.errorsHandler.isActive())) {
|
|
11501
|
-
this.channel = null;
|
|
11502
|
-
}
|
|
11503
|
-
}
|
|
11504
|
-
if (this.lastCode === 1 && this.errorsHandler.isActive()) {
|
|
11505
|
-
this.lastCode = 0;
|
|
11506
|
-
this.commandsQueue.push(this.currentOptions);
|
|
11507
|
-
this.errorsHandler.delay(function () {
|
|
11508
|
-
_this.next();
|
|
11509
|
-
});
|
|
11510
|
-
return this.promise;
|
|
11511
|
-
}
|
|
11512
|
-
if (this.commandsQueue.length === 0) {
|
|
11513
|
-
if (this.state !== ShellState.Empty) {
|
|
11514
|
-
this.state = ShellState.Empty;
|
|
11515
|
-
this.end = new Date();
|
|
11516
|
-
this.isBusy = false;
|
|
11517
|
-
var promise = this.promise;
|
|
11518
|
-
// Always resolve the promise, consumer should check for errors
|
|
11519
|
-
promise.resolve(this);
|
|
11520
|
-
}
|
|
11521
|
-
return this.promise;
|
|
11522
|
-
}
|
|
11523
|
-
var child = null;
|
|
11524
|
-
var options = this.commandsQueue.shift();
|
|
11525
|
-
var command = ValueExtractor_1.ValueExtractor.interpolateAny(options.command, this.extracted);
|
|
11526
|
-
var rgxReady = options.matchReady;
|
|
11527
|
-
var detached = options.detached === true;
|
|
11528
|
-
var silent = this.params.silent;
|
|
11529
|
-
var stdio = detached ? (void 0) : 'pipe';
|
|
11530
|
-
var extractor = options.extract ? new ValueExtractor_1.ValueExtractor(this.extracted, options.extract) : null;
|
|
11531
|
-
var result = new ProcessResult(options);
|
|
11532
|
-
this.results.push(result);
|
|
11533
|
-
this.currentOptions = options;
|
|
11534
|
-
if (!options.fork && global.process.platform === 'win32') {
|
|
11535
|
-
if (options.exec !== 'cmd') {
|
|
11536
|
-
options.args.unshift('/C', options.exec);
|
|
11537
|
-
options.exec = 'cmd';
|
|
11538
|
-
}
|
|
11539
|
-
}
|
|
11540
|
-
if (rgxReady == null && options.ipc) {
|
|
11541
|
-
rgxReady = /IPC Listening/i;
|
|
11542
|
-
}
|
|
11543
|
-
this.isReady = rgxReady == null;
|
|
11544
|
-
try {
|
|
11545
|
-
var cwd = options.cwd;
|
|
11546
|
-
if (cwd != null) {
|
|
11547
|
-
var hasFileProtocol = cwd.startsWith('file:');
|
|
11548
|
-
var cwdUri = hasFileProtocol ? cwd : 'file://' + cwd;
|
|
11549
|
-
if (atma_io_1.Directory.exists(cwdUri + '/') === false) {
|
|
11550
|
-
throw Error('CWD Directory not exists: ' + cwd);
|
|
11551
|
-
}
|
|
11552
|
-
if (hasFileProtocol) {
|
|
11553
|
-
cwd = new atma_utils_1.class_Uri(cwd).toLocalDir();
|
|
11554
|
-
}
|
|
11555
|
-
}
|
|
11556
|
-
if (cwd == null) {
|
|
11557
|
-
cwd = process.cwd();
|
|
11558
|
-
}
|
|
11559
|
-
var exec = ValueExtractor_1.ValueExtractor.interpolateAny(options.exec, this.extracted, options);
|
|
11560
|
-
var args = ValueExtractor_1.ValueExtractor.interpolateAny(options.args, this.extracted, options);
|
|
11561
|
-
var method = options.fork ? 'fork' : 'spawn';
|
|
11562
|
-
if (this.params.verbose) {
|
|
11563
|
-
this.print("".concat(method, ": ").concat(exec, " ").concat(args.join('')));
|
|
11564
|
-
}
|
|
11565
|
-
child = options.fork
|
|
11566
|
-
? child_process.fork(exec, args, {
|
|
11567
|
-
cwd: options.cwd || process.cwd(),
|
|
11568
|
-
env: process.env,
|
|
11569
|
-
stdio: stdio,
|
|
11570
|
-
detached: detached
|
|
11571
|
-
})
|
|
11572
|
-
: child_process.spawn(exec, args, {
|
|
11573
|
-
cwd: options.cwd || process.cwd(),
|
|
11574
|
-
env: process.env,
|
|
11575
|
-
stdio: stdio,
|
|
11576
|
-
detached: detached
|
|
11577
|
-
});
|
|
11578
|
-
if (options.fork) {
|
|
11579
|
-
this.channel = new CommunicationChannel_1.CommunicationChannel(child, (_a = this.params.timeoutMs) !== null && _a !== void 0 ? _a : 10000);
|
|
11580
|
-
this.emit('channel_created', {
|
|
11581
|
-
channel: this.channel
|
|
11582
|
-
});
|
|
11583
|
-
}
|
|
11584
|
-
result.pid = child.pid;
|
|
11585
|
-
this.children.push({
|
|
11586
|
-
process: child,
|
|
11587
|
-
options: options,
|
|
11588
|
-
});
|
|
11589
|
-
}
|
|
11590
|
-
catch (error) {
|
|
11591
|
-
if (this.params.verbose) {
|
|
11592
|
-
this.print('on start exception:', error);
|
|
11593
|
-
}
|
|
11594
|
-
result.error = error;
|
|
11595
|
-
this.errors.push({
|
|
11596
|
-
command: command,
|
|
11597
|
-
error: error
|
|
11598
|
-
});
|
|
11599
|
-
this.emit('process_exception', {
|
|
11600
|
-
command: command,
|
|
11601
|
-
error: error
|
|
11602
|
-
});
|
|
11603
|
-
return this.next();
|
|
11604
|
-
}
|
|
11605
|
-
child.on('error', function (error) {
|
|
11606
|
-
var _a;
|
|
11607
|
-
if (_this.params.verbose) {
|
|
11608
|
-
_this.print('on error:', error);
|
|
11609
|
-
}
|
|
11610
|
-
(_a = _this.channel) === null || _a === void 0 ? void 0 : _a.onError(error);
|
|
11611
|
-
});
|
|
11612
|
-
child.on('exit', function (code) {
|
|
11613
|
-
var _a;
|
|
11614
|
-
if (_this.params.verbose) {
|
|
11615
|
-
_this.print('on exit:', code);
|
|
11616
|
-
}
|
|
11617
|
-
result.resultCode = code !== null && code !== void 0 ? code : 0;
|
|
11618
|
-
_this.emit('process_exit', {
|
|
11619
|
-
command: command,
|
|
11620
|
-
code: code,
|
|
11621
|
-
result: result
|
|
11622
|
-
});
|
|
11623
|
-
_this.isBusy = false;
|
|
11624
|
-
_this.isReady = false;
|
|
11625
|
-
_this.lastCode = code;
|
|
11626
|
-
if (code > 0) {
|
|
11627
|
-
var msg = result.stderr.slice(-20).join('');
|
|
11628
|
-
var err = new Error("Exit code: ".concat(code, ". ").concat(msg !== null && msg !== void 0 ? msg : ''));
|
|
11629
|
-
_this.errors.push({
|
|
11630
|
-
command: command,
|
|
11631
|
-
error: err
|
|
11632
|
-
});
|
|
11633
|
-
(_a = _this.channel) === null || _a === void 0 ? void 0 : _a.onError(err);
|
|
11634
|
-
}
|
|
11635
|
-
extractor === null || extractor === void 0 ? void 0 : extractor.complete();
|
|
11636
|
-
_this.next();
|
|
11637
|
-
});
|
|
11638
|
-
child.stdout.on('data', function (buffer) {
|
|
11639
|
-
if (detached !== true && silent !== true) {
|
|
11640
|
-
process.stdout.write(buffer);
|
|
11641
|
-
}
|
|
11642
|
-
if (rgxReady != null && rgxReady.test(buffer.toString())) {
|
|
11643
|
-
rgxReady = null;
|
|
11644
|
-
_this.isReady = true;
|
|
11645
|
-
_this.emit('process_ready', {
|
|
11646
|
-
command: command
|
|
11647
|
-
});
|
|
11648
|
-
}
|
|
11649
|
-
if (extractor != null) {
|
|
11650
|
-
extractor.write(buffer);
|
|
11651
|
-
}
|
|
11652
|
-
var str = String(buffer);
|
|
11653
|
-
result.stdout.push(str);
|
|
11654
|
-
result.std.push(str);
|
|
11655
|
-
_this.stdout.push(str);
|
|
11656
|
-
_this.std.push(str);
|
|
11657
|
-
_this.emit('process_stdout', {
|
|
11658
|
-
command: command,
|
|
11659
|
-
buffer: buffer
|
|
11660
|
-
});
|
|
11661
|
-
});
|
|
11662
|
-
child.stderr.on('data', function (buffer) {
|
|
11663
|
-
var _a;
|
|
11664
|
-
if (detached !== true && silent !== true) {
|
|
11665
|
-
process.stderr.write(buffer);
|
|
11666
|
-
}
|
|
11667
|
-
var str = String(buffer);
|
|
11668
|
-
result.stderr.push(str);
|
|
11669
|
-
result.std.push(str);
|
|
11670
|
-
_this.stderr.push(str);
|
|
11671
|
-
_this.std.push(str);
|
|
11672
|
-
_this.emit('process_stderr', {
|
|
11673
|
-
command: command,
|
|
11674
|
-
buffer: buffer
|
|
11675
|
-
});
|
|
11676
|
-
if (str.includes('UnhandledPromiseRejectionWarning')) {
|
|
11677
|
-
(_a = _this.channel) === null || _a === void 0 ? void 0 : _a.onStdError(str);
|
|
11678
|
-
}
|
|
11679
|
-
});
|
|
11680
|
-
this.emit('process_start', {
|
|
11681
|
-
command: command
|
|
11682
|
-
});
|
|
11683
|
-
if (this.params.parallel !== false) {
|
|
11684
|
-
this.next();
|
|
11685
|
-
}
|
|
11686
|
-
if (rgxReady == null) {
|
|
11687
|
-
setTimeout(function () {
|
|
11688
|
-
_this.emit('process_ready', {
|
|
11689
|
-
command: command
|
|
11690
|
-
});
|
|
11691
|
-
}, 200);
|
|
11692
|
-
}
|
|
11693
|
-
return this.promise;
|
|
11694
|
-
};
|
|
11695
|
-
Shell.prototype.print = function () {
|
|
11696
|
-
var args = [];
|
|
11697
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
11698
|
-
args[_i] = arguments[_i];
|
|
11699
|
-
}
|
|
11700
|
-
console.log('Shellbee: ' + args.join(' '));
|
|
11701
|
-
};
|
|
11702
|
-
Shell.ipc = CommunicationChannel_1.CommunicationChannel.ipc;
|
|
11703
|
-
return Shell;
|
|
11704
|
-
}(atma_utils_1.class_EventEmitter));
|
|
11705
|
-
exports.Shell = Shell;
|
|
11706
|
-
;
|
|
11707
|
-
var ProcessResult = /** @class */ (function () {
|
|
11708
|
-
function ProcessResult(options) {
|
|
11709
|
-
this.options = options;
|
|
11710
|
-
this.std = [];
|
|
11711
|
-
this.stdout = [];
|
|
11712
|
-
this.stderr = [];
|
|
11713
|
-
this.resultCode = null;
|
|
11714
|
-
this.error = null;
|
|
11715
|
-
}
|
|
11716
|
-
return ProcessResult;
|
|
11717
|
-
}());
|
|
11718
|
-
exports.ProcessResult = ProcessResult;
|
|
11719
|
-
var ShellState;
|
|
11720
|
-
(function (ShellState) {
|
|
11721
|
-
ShellState[ShellState["Empty"] = -1] = "Empty";
|
|
11722
|
-
ShellState[ShellState["Initial"] = 0] = "Initial";
|
|
11723
|
-
ShellState[ShellState["Started"] = 1] = "Started";
|
|
11724
|
-
})(ShellState || (ShellState = {}));
|
|
11177
|
+
"use strict";
|
|
11178
|
+
var __extends = (this && this.__extends) || (function () {
|
|
11179
|
+
var extendStatics = function (d, b) {
|
|
11180
|
+
extendStatics = Object.setPrototypeOf ||
|
|
11181
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
11182
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
11183
|
+
return extendStatics(d, b);
|
|
11184
|
+
};
|
|
11185
|
+
return function (d, b) {
|
|
11186
|
+
if (typeof b !== "function" && b !== null)
|
|
11187
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
11188
|
+
extendStatics(d, b);
|
|
11189
|
+
function __() { this.constructor = d; }
|
|
11190
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
11191
|
+
};
|
|
11192
|
+
})();
|
|
11193
|
+
var __assign = (this && this.__assign) || function () {
|
|
11194
|
+
__assign = Object.assign || function(t) {
|
|
11195
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
11196
|
+
s = arguments[i];
|
|
11197
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
11198
|
+
t[p] = s[p];
|
|
11199
|
+
}
|
|
11200
|
+
return t;
|
|
11201
|
+
};
|
|
11202
|
+
return __assign.apply(this, arguments);
|
|
11203
|
+
};
|
|
11204
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
11205
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
11206
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
11207
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
11208
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
11209
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
11210
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
11211
|
+
});
|
|
11212
|
+
};
|
|
11213
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11214
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
11215
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
11216
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
11217
|
+
function step(op) {
|
|
11218
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
11219
|
+
while (_) try {
|
|
11220
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
11221
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
11222
|
+
switch (op[0]) {
|
|
11223
|
+
case 0: case 1: t = op; break;
|
|
11224
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
11225
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
11226
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
11227
|
+
default:
|
|
11228
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
11229
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
11230
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
11231
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
11232
|
+
if (t[2]) _.ops.pop();
|
|
11233
|
+
_.trys.pop(); continue;
|
|
11234
|
+
}
|
|
11235
|
+
op = body.call(thisArg, _);
|
|
11236
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
11237
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
11238
|
+
}
|
|
11239
|
+
};
|
|
11240
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
11241
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
11242
|
+
if (ar || !(i in from)) {
|
|
11243
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
11244
|
+
ar[i] = from[i];
|
|
11245
|
+
}
|
|
11246
|
+
}
|
|
11247
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
11248
|
+
};
|
|
11249
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11250
|
+
exports.ProcessResult = exports.Shell = void 0;
|
|
11251
|
+
var atma_utils_1 = require("atma-utils");
|
|
11252
|
+
var atma_io_1 = require("atma-io");
|
|
11253
|
+
var child_process = require("child_process");
|
|
11254
|
+
var command_1 = _src_util_command;
|
|
11255
|
+
var ValueExtractor_1 = _src_ValueExtractor;
|
|
11256
|
+
var CommunicationChannel_1 = _src_CommunicationChannel;
|
|
11257
|
+
var events_1 = _src_util_events;
|
|
11258
|
+
var treeKill = require("tree-kill");
|
|
11259
|
+
var ShellParamsUtil_1 = _src_util_ShellParamsUtil;
|
|
11260
|
+
var ShellErrorExitsHandler_1 = _src_util_ShellErrorExitsHandler;
|
|
11261
|
+
var ShellStalledOutputHandler_1 = _src_util_ShellStalledOutputHandler;
|
|
11262
|
+
var Shell = /** @class */ (function (_super) {
|
|
11263
|
+
__extends(Shell, _super);
|
|
11264
|
+
function Shell(params) {
|
|
11265
|
+
var _this = _super.call(this) || this;
|
|
11266
|
+
_this.children = [];
|
|
11267
|
+
_this.errors = [];
|
|
11268
|
+
_this.lastCode = 0;
|
|
11269
|
+
_this.results = [];
|
|
11270
|
+
_this.extracted = {};
|
|
11271
|
+
_this.state = ShellState.Initial;
|
|
11272
|
+
_this.promise = new atma_utils_1.class_Dfr();
|
|
11273
|
+
_this.std = [];
|
|
11274
|
+
_this.stderr = [];
|
|
11275
|
+
_this.stdout = [];
|
|
11276
|
+
_this.isBusy = false;
|
|
11277
|
+
_this.isReady = false;
|
|
11278
|
+
_this.params = ShellParamsUtil_1.ShellParamsUtil.normalize(params);
|
|
11279
|
+
_this.errorsHandler = new ShellErrorExitsHandler_1.ShellErrorExitsHandler(_this.params);
|
|
11280
|
+
_this.stalledOutputHandler = new ShellStalledOutputHandler_1.ShellStalledOutputHandler(_this.params, _this);
|
|
11281
|
+
_this.stalledOutputHandler.init();
|
|
11282
|
+
_this.commands = (0, command_1.command_parseAll)(params.commands, params);
|
|
11283
|
+
_this.commandsQueue = _this.commands.slice();
|
|
11284
|
+
_this.on('process_start', function () {
|
|
11285
|
+
_this.state = ShellState.Started;
|
|
11286
|
+
});
|
|
11287
|
+
return _this;
|
|
11288
|
+
}
|
|
11289
|
+
Shell.run = function (mix) {
|
|
11290
|
+
var params;
|
|
11291
|
+
if (typeof mix === 'string') {
|
|
11292
|
+
params = { command: mix };
|
|
11293
|
+
}
|
|
11294
|
+
else if (Array.isArray(mix)) {
|
|
11295
|
+
params = { commands: mix };
|
|
11296
|
+
}
|
|
11297
|
+
else {
|
|
11298
|
+
params = mix;
|
|
11299
|
+
}
|
|
11300
|
+
return new Shell(params).run();
|
|
11301
|
+
};
|
|
11302
|
+
/**
|
|
11303
|
+
* "Run" starts the command
|
|
11304
|
+
* @returns Promise, which is resolved after the executables are completed.
|
|
11305
|
+
*/
|
|
11306
|
+
Shell.prototype.run = function () {
|
|
11307
|
+
if (this.isBusy === false) {
|
|
11308
|
+
this.next();
|
|
11309
|
+
return this.promise;
|
|
11310
|
+
}
|
|
11311
|
+
return this.promise;
|
|
11312
|
+
};
|
|
11313
|
+
Shell.factory = function (config) {
|
|
11314
|
+
return {
|
|
11315
|
+
run: function (mix) {
|
|
11316
|
+
var params;
|
|
11317
|
+
if (typeof mix === 'string') {
|
|
11318
|
+
params = { command: mix };
|
|
11319
|
+
}
|
|
11320
|
+
else if (Array.isArray(mix)) {
|
|
11321
|
+
params = { commands: mix };
|
|
11322
|
+
}
|
|
11323
|
+
else {
|
|
11324
|
+
params = mix;
|
|
11325
|
+
}
|
|
11326
|
+
return Shell.run(__assign(__assign({}, config), params));
|
|
11327
|
+
}
|
|
11328
|
+
};
|
|
11329
|
+
};
|
|
11330
|
+
Shell.prototype.onStart = function (cb) {
|
|
11331
|
+
return this.on('process_start', cb);
|
|
11332
|
+
};
|
|
11333
|
+
Shell.prototype.onStdout = function (cb) {
|
|
11334
|
+
return this.on('process_stdout', cb);
|
|
11335
|
+
};
|
|
11336
|
+
Shell.prototype.onStderr = function (cb) {
|
|
11337
|
+
return this.on('process_stderr', cb);
|
|
11338
|
+
};
|
|
11339
|
+
Shell.prototype.onExit = function (cb) {
|
|
11340
|
+
return this.on('process_exit', cb);
|
|
11341
|
+
};
|
|
11342
|
+
/** When rgxReady is specified the event will be called */
|
|
11343
|
+
Shell.prototype.onReady = function (cb) {
|
|
11344
|
+
var _a, _b, _c, _d, _e, _f;
|
|
11345
|
+
var isAlreadyCompleted = this.isBusy === false && this.lastCode != null;
|
|
11346
|
+
var isReady = this.isReady;
|
|
11347
|
+
if (isReady || isAlreadyCompleted) {
|
|
11348
|
+
cb({ command: (_a = this.currentOptions) === null || _a === void 0 ? void 0 : _a.command });
|
|
11349
|
+
return;
|
|
11350
|
+
}
|
|
11351
|
+
if (!((_b = this.currentOptions) === null || _b === void 0 ? void 0 : _b.matchReady) && this.commandsQueue.some(function (x) { return x.matchReady; }) === false) {
|
|
11352
|
+
console.error('Ready Matcher Regex is not defined', (_d = (_c = this.currentOptions) === null || _c === void 0 ? void 0 : _c.command) !== null && _d !== void 0 ? _d : (_f = (_e = this.commands) === null || _e === void 0 ? void 0 : _e[0]) === null || _f === void 0 ? void 0 : _f.command);
|
|
11353
|
+
}
|
|
11354
|
+
return this.on('process_ready', cb);
|
|
11355
|
+
};
|
|
11356
|
+
Shell.prototype.onReadyAsync = function () {
|
|
11357
|
+
var _this = this;
|
|
11358
|
+
return new Promise(function (resolve) {
|
|
11359
|
+
_this.onReady(resolve);
|
|
11360
|
+
});
|
|
11361
|
+
};
|
|
11362
|
+
Shell.prototype.onComplete = function (cb) {
|
|
11363
|
+
var _this = this;
|
|
11364
|
+
this.promise.always(function () { return cb(_this); });
|
|
11365
|
+
return this;
|
|
11366
|
+
};
|
|
11367
|
+
Shell.prototype.onCompleteAsync = function () {
|
|
11368
|
+
var _this = this;
|
|
11369
|
+
return new Promise(function (resolve) {
|
|
11370
|
+
_this.onComplete(resolve);
|
|
11371
|
+
});
|
|
11372
|
+
};
|
|
11373
|
+
Shell.prototype.kill = function (mix) {
|
|
11374
|
+
var _this = this;
|
|
11375
|
+
var _a, _b, _c;
|
|
11376
|
+
var signal = 'SIGINT';
|
|
11377
|
+
var commandIdx = 0;
|
|
11378
|
+
var terminateAfterMs = null;
|
|
11379
|
+
if (mix != null) {
|
|
11380
|
+
signal = (_a = (typeof mix === 'object' ? mix.signal : mix)) !== null && _a !== void 0 ? _a : signal;
|
|
11381
|
+
if (typeof mix === 'object') {
|
|
11382
|
+
commandIdx = (_b = mix.commandIdx) !== null && _b !== void 0 ? _b : commandIdx;
|
|
11383
|
+
terminateAfterMs = (_c = mix.terminateAfter) !== null && _c !== void 0 ? _c : terminateAfterMs;
|
|
11384
|
+
}
|
|
11385
|
+
}
|
|
11386
|
+
return new Promise(function (resolve) {
|
|
11387
|
+
var isCompleted = _this.isBusy === false && _this.lastCode != null;
|
|
11388
|
+
if (isCompleted) {
|
|
11389
|
+
return resolve(null);
|
|
11390
|
+
}
|
|
11391
|
+
var options = _this.commands[commandIdx];
|
|
11392
|
+
var child = _this.children.find(function (x) { return x.options === options; });
|
|
11393
|
+
if (child == null) {
|
|
11394
|
+
return resolve(null);
|
|
11395
|
+
}
|
|
11396
|
+
var i = _this.children.indexOf(child);
|
|
11397
|
+
_this.children.splice(i, 1);
|
|
11398
|
+
var timeout;
|
|
11399
|
+
child.process.kill(signal);
|
|
11400
|
+
_this.once('process_exit', function () {
|
|
11401
|
+
if (timeout != null) {
|
|
11402
|
+
clearTimeout(timeout);
|
|
11403
|
+
}
|
|
11404
|
+
resolve(null);
|
|
11405
|
+
});
|
|
11406
|
+
if (terminateAfterMs != null) {
|
|
11407
|
+
timeout = setTimeout(function () {
|
|
11408
|
+
treeKill(child.process.pid);
|
|
11409
|
+
}, terminateAfterMs);
|
|
11410
|
+
}
|
|
11411
|
+
});
|
|
11412
|
+
};
|
|
11413
|
+
/** Uses tree-kill to terminate the tree */
|
|
11414
|
+
Shell.prototype.terminate = function () {
|
|
11415
|
+
var _this = this;
|
|
11416
|
+
return new Promise(function (resolve) {
|
|
11417
|
+
var child = _this.children.pop();
|
|
11418
|
+
if (child == null) {
|
|
11419
|
+
return resolve(null);
|
|
11420
|
+
}
|
|
11421
|
+
_this.once('process_exit', resolve);
|
|
11422
|
+
treeKill(child.process.pid);
|
|
11423
|
+
});
|
|
11424
|
+
};
|
|
11425
|
+
Shell.prototype.send = function (method) {
|
|
11426
|
+
var _this = this;
|
|
11427
|
+
var args = [];
|
|
11428
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
11429
|
+
args[_i - 1] = arguments[_i];
|
|
11430
|
+
}
|
|
11431
|
+
return new Promise(function (resolve, reject) {
|
|
11432
|
+
_this.waitForChannel().then(function (channel) {
|
|
11433
|
+
channel.call.apply(channel, __spreadArray([method], args, false)).then(resolve, reject);
|
|
11434
|
+
}, reject);
|
|
11435
|
+
});
|
|
11436
|
+
};
|
|
11437
|
+
Shell.prototype.restart = function (mix) {
|
|
11438
|
+
if (mix === void 0) { mix = 0; }
|
|
11439
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
11440
|
+
var options;
|
|
11441
|
+
return __generator(this, function (_a) {
|
|
11442
|
+
switch (_a.label) {
|
|
11443
|
+
case 0:
|
|
11444
|
+
if (typeof mix === 'number') {
|
|
11445
|
+
options = this.commands[mix];
|
|
11446
|
+
}
|
|
11447
|
+
else {
|
|
11448
|
+
options = this.commands.find(function (x) { return x.command === mix; });
|
|
11449
|
+
}
|
|
11450
|
+
if (options == null) {
|
|
11451
|
+
throw new Error("Options undefined for ".concat(mix));
|
|
11452
|
+
}
|
|
11453
|
+
this.commandsQueue.push(options);
|
|
11454
|
+
if (this.isBusy === false) {
|
|
11455
|
+
this.next();
|
|
11456
|
+
return [2 /*return*/];
|
|
11457
|
+
}
|
|
11458
|
+
// `next` will be called indirect (after the process exits)
|
|
11459
|
+
return [4 /*yield*/, this.kill({ terminateAfter: 10000 })];
|
|
11460
|
+
case 1:
|
|
11461
|
+
// `next` will be called indirect (after the process exits)
|
|
11462
|
+
_a.sent();
|
|
11463
|
+
return [2 /*return*/];
|
|
11464
|
+
}
|
|
11465
|
+
});
|
|
11466
|
+
});
|
|
11467
|
+
};
|
|
11468
|
+
Shell.prototype.waitForChannel = function () {
|
|
11469
|
+
var _this = this;
|
|
11470
|
+
if (this.currentOptions.ipc && this.isReady === false) {
|
|
11471
|
+
return new Promise(function (resolve, reject) {
|
|
11472
|
+
(0, events_1.events_someOnce)(_this, {
|
|
11473
|
+
'process_ready': function () {
|
|
11474
|
+
_this.waitForChannel().then(resolve, reject);
|
|
11475
|
+
},
|
|
11476
|
+
'exit': function () {
|
|
11477
|
+
reject('Process exited');
|
|
11478
|
+
}
|
|
11479
|
+
});
|
|
11480
|
+
});
|
|
11481
|
+
}
|
|
11482
|
+
return new Promise(function (resolve, reject) {
|
|
11483
|
+
if (_this.channel) {
|
|
11484
|
+
resolve(_this.channel);
|
|
11485
|
+
return;
|
|
11486
|
+
}
|
|
11487
|
+
(0, events_1.events_someOnce)(_this, {
|
|
11488
|
+
'channel_created': function () {
|
|
11489
|
+
resolve(_this.channel);
|
|
11490
|
+
},
|
|
11491
|
+
'exit': function () {
|
|
11492
|
+
reject('Process exited');
|
|
11493
|
+
}
|
|
11494
|
+
});
|
|
11495
|
+
});
|
|
11496
|
+
};
|
|
11497
|
+
Shell.prototype.next = function () {
|
|
11498
|
+
var _this = this;
|
|
11499
|
+
var _a;
|
|
11500
|
+
if (this.isBusy === false) {
|
|
11501
|
+
this.start = new Date();
|
|
11502
|
+
this.isBusy = true;
|
|
11503
|
+
this.isReady = false;
|
|
11504
|
+
}
|
|
11505
|
+
if (this.channel) {
|
|
11506
|
+
this.emit('channel_closed', {
|
|
11507
|
+
channel: this.channel
|
|
11508
|
+
});
|
|
11509
|
+
if (this.commandsQueue.length !== 0 || (this.lastCode === 1 && this.errorsHandler.isActive())) {
|
|
11510
|
+
this.channel = null;
|
|
11511
|
+
}
|
|
11512
|
+
}
|
|
11513
|
+
if (this.lastCode === 1 && this.errorsHandler.isActive()) {
|
|
11514
|
+
this.lastCode = 0;
|
|
11515
|
+
this.commandsQueue.push(this.currentOptions);
|
|
11516
|
+
this.errorsHandler.delay(function () {
|
|
11517
|
+
_this.next();
|
|
11518
|
+
});
|
|
11519
|
+
return this.promise;
|
|
11520
|
+
}
|
|
11521
|
+
if (this.commandsQueue.length === 0) {
|
|
11522
|
+
if (this.state !== ShellState.Empty) {
|
|
11523
|
+
this.state = ShellState.Empty;
|
|
11524
|
+
this.end = new Date();
|
|
11525
|
+
this.isBusy = false;
|
|
11526
|
+
var promise = this.promise;
|
|
11527
|
+
// Always resolve the promise, consumer should check for errors
|
|
11528
|
+
promise.resolve(this);
|
|
11529
|
+
}
|
|
11530
|
+
return this.promise;
|
|
11531
|
+
}
|
|
11532
|
+
var child = null;
|
|
11533
|
+
var options = this.commandsQueue.shift();
|
|
11534
|
+
var command = ValueExtractor_1.ValueExtractor.interpolateAny(options.command, this.extracted);
|
|
11535
|
+
var rgxReady = options.matchReady;
|
|
11536
|
+
var detached = options.detached === true;
|
|
11537
|
+
var silent = this.params.silent;
|
|
11538
|
+
var stdio = detached ? (void 0) : 'pipe';
|
|
11539
|
+
var extractor = options.extract ? new ValueExtractor_1.ValueExtractor(this.extracted, options.extract) : null;
|
|
11540
|
+
var result = new ProcessResult(options);
|
|
11541
|
+
this.results.push(result);
|
|
11542
|
+
this.currentOptions = options;
|
|
11543
|
+
if (!options.fork && global.process.platform === 'win32') {
|
|
11544
|
+
if (options.exec !== 'cmd') {
|
|
11545
|
+
options.args.unshift('/C', options.exec);
|
|
11546
|
+
options.exec = 'cmd';
|
|
11547
|
+
}
|
|
11548
|
+
}
|
|
11549
|
+
if (rgxReady == null && options.ipc) {
|
|
11550
|
+
rgxReady = /IPC Listening/i;
|
|
11551
|
+
}
|
|
11552
|
+
this.isReady = rgxReady == null;
|
|
11553
|
+
try {
|
|
11554
|
+
var cwd = options.cwd;
|
|
11555
|
+
if (cwd != null) {
|
|
11556
|
+
var hasFileProtocol = cwd.startsWith('file:');
|
|
11557
|
+
var cwdUri = hasFileProtocol ? cwd : 'file://' + cwd;
|
|
11558
|
+
if (atma_io_1.Directory.exists(cwdUri + '/') === false) {
|
|
11559
|
+
throw Error('CWD Directory not exists: ' + cwd);
|
|
11560
|
+
}
|
|
11561
|
+
if (hasFileProtocol) {
|
|
11562
|
+
cwd = new atma_utils_1.class_Uri(cwd).toLocalDir();
|
|
11563
|
+
}
|
|
11564
|
+
}
|
|
11565
|
+
if (cwd == null) {
|
|
11566
|
+
cwd = process.cwd();
|
|
11567
|
+
}
|
|
11568
|
+
var exec = ValueExtractor_1.ValueExtractor.interpolateAny(options.exec, this.extracted, options);
|
|
11569
|
+
var args = ValueExtractor_1.ValueExtractor.interpolateAny(options.args, this.extracted, options);
|
|
11570
|
+
var method = options.fork ? 'fork' : 'spawn';
|
|
11571
|
+
if (this.params.verbose) {
|
|
11572
|
+
this.print("".concat(method, ": ").concat(exec, " ").concat(args.join('')));
|
|
11573
|
+
}
|
|
11574
|
+
child = options.fork
|
|
11575
|
+
? child_process.fork(exec, args, {
|
|
11576
|
+
cwd: options.cwd || process.cwd(),
|
|
11577
|
+
env: process.env,
|
|
11578
|
+
stdio: stdio,
|
|
11579
|
+
detached: detached
|
|
11580
|
+
})
|
|
11581
|
+
: child_process.spawn(exec, args, {
|
|
11582
|
+
cwd: options.cwd || process.cwd(),
|
|
11583
|
+
env: process.env,
|
|
11584
|
+
stdio: stdio,
|
|
11585
|
+
detached: detached
|
|
11586
|
+
});
|
|
11587
|
+
if (options.fork) {
|
|
11588
|
+
this.channel = new CommunicationChannel_1.CommunicationChannel(child, (_a = this.params.timeoutMs) !== null && _a !== void 0 ? _a : 10000);
|
|
11589
|
+
this.emit('channel_created', {
|
|
11590
|
+
channel: this.channel
|
|
11591
|
+
});
|
|
11592
|
+
}
|
|
11593
|
+
result.pid = child.pid;
|
|
11594
|
+
this.children.push({
|
|
11595
|
+
process: child,
|
|
11596
|
+
options: options,
|
|
11597
|
+
});
|
|
11598
|
+
}
|
|
11599
|
+
catch (error) {
|
|
11600
|
+
if (this.params.verbose) {
|
|
11601
|
+
this.print('on start exception:', error);
|
|
11602
|
+
}
|
|
11603
|
+
result.error = error;
|
|
11604
|
+
this.errors.push({
|
|
11605
|
+
command: command,
|
|
11606
|
+
error: error
|
|
11607
|
+
});
|
|
11608
|
+
this.emit('process_exception', {
|
|
11609
|
+
command: command,
|
|
11610
|
+
error: error
|
|
11611
|
+
});
|
|
11612
|
+
return this.next();
|
|
11613
|
+
}
|
|
11614
|
+
child.on('error', function (error) {
|
|
11615
|
+
var _a;
|
|
11616
|
+
if (_this.params.verbose) {
|
|
11617
|
+
_this.print('on error:', error);
|
|
11618
|
+
}
|
|
11619
|
+
(_a = _this.channel) === null || _a === void 0 ? void 0 : _a.onError(error);
|
|
11620
|
+
});
|
|
11621
|
+
child.on('exit', function (code) {
|
|
11622
|
+
var _a;
|
|
11623
|
+
if (_this.params.verbose) {
|
|
11624
|
+
_this.print('on exit:', code);
|
|
11625
|
+
}
|
|
11626
|
+
result.resultCode = code !== null && code !== void 0 ? code : 0;
|
|
11627
|
+
_this.emit('process_exit', {
|
|
11628
|
+
command: command,
|
|
11629
|
+
code: code,
|
|
11630
|
+
result: result
|
|
11631
|
+
});
|
|
11632
|
+
_this.isBusy = false;
|
|
11633
|
+
_this.isReady = false;
|
|
11634
|
+
_this.lastCode = code;
|
|
11635
|
+
if (code > 0) {
|
|
11636
|
+
var msg = result.stderr.slice(-20).join('');
|
|
11637
|
+
var err = new Error("Exit code: ".concat(code, ". ").concat(msg !== null && msg !== void 0 ? msg : ''));
|
|
11638
|
+
_this.errors.push({
|
|
11639
|
+
command: command,
|
|
11640
|
+
error: err
|
|
11641
|
+
});
|
|
11642
|
+
(_a = _this.channel) === null || _a === void 0 ? void 0 : _a.onError(err);
|
|
11643
|
+
}
|
|
11644
|
+
extractor === null || extractor === void 0 ? void 0 : extractor.complete();
|
|
11645
|
+
_this.next();
|
|
11646
|
+
});
|
|
11647
|
+
child.stdout.on('data', function (buffer) {
|
|
11648
|
+
if (detached !== true && silent !== true) {
|
|
11649
|
+
process.stdout.write(buffer);
|
|
11650
|
+
}
|
|
11651
|
+
if (rgxReady != null && rgxReady.test(buffer.toString())) {
|
|
11652
|
+
rgxReady = null;
|
|
11653
|
+
_this.isReady = true;
|
|
11654
|
+
_this.emit('process_ready', {
|
|
11655
|
+
command: command
|
|
11656
|
+
});
|
|
11657
|
+
}
|
|
11658
|
+
if (extractor != null) {
|
|
11659
|
+
extractor.write(buffer);
|
|
11660
|
+
}
|
|
11661
|
+
var str = String(buffer);
|
|
11662
|
+
result.stdout.push(str);
|
|
11663
|
+
result.std.push(str);
|
|
11664
|
+
_this.stdout.push(str);
|
|
11665
|
+
_this.std.push(str);
|
|
11666
|
+
_this.emit('process_stdout', {
|
|
11667
|
+
command: command,
|
|
11668
|
+
buffer: buffer
|
|
11669
|
+
});
|
|
11670
|
+
});
|
|
11671
|
+
child.stderr.on('data', function (buffer) {
|
|
11672
|
+
var _a;
|
|
11673
|
+
if (detached !== true && silent !== true) {
|
|
11674
|
+
process.stderr.write(buffer);
|
|
11675
|
+
}
|
|
11676
|
+
var str = String(buffer);
|
|
11677
|
+
result.stderr.push(str);
|
|
11678
|
+
result.std.push(str);
|
|
11679
|
+
_this.stderr.push(str);
|
|
11680
|
+
_this.std.push(str);
|
|
11681
|
+
_this.emit('process_stderr', {
|
|
11682
|
+
command: command,
|
|
11683
|
+
buffer: buffer
|
|
11684
|
+
});
|
|
11685
|
+
if (str.includes('UnhandledPromiseRejectionWarning')) {
|
|
11686
|
+
(_a = _this.channel) === null || _a === void 0 ? void 0 : _a.onStdError(str);
|
|
11687
|
+
}
|
|
11688
|
+
});
|
|
11689
|
+
this.emit('process_start', {
|
|
11690
|
+
command: command
|
|
11691
|
+
});
|
|
11692
|
+
if (this.params.parallel !== false) {
|
|
11693
|
+
this.next();
|
|
11694
|
+
}
|
|
11695
|
+
if (rgxReady == null) {
|
|
11696
|
+
setTimeout(function () {
|
|
11697
|
+
_this.emit('process_ready', {
|
|
11698
|
+
command: command
|
|
11699
|
+
});
|
|
11700
|
+
}, 200);
|
|
11701
|
+
}
|
|
11702
|
+
return this.promise;
|
|
11703
|
+
};
|
|
11704
|
+
Shell.prototype.print = function () {
|
|
11705
|
+
var args = [];
|
|
11706
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
11707
|
+
args[_i] = arguments[_i];
|
|
11708
|
+
}
|
|
11709
|
+
console.log('Shellbee: ' + args.join(' '));
|
|
11710
|
+
};
|
|
11711
|
+
Shell.ipc = CommunicationChannel_1.CommunicationChannel.ipc;
|
|
11712
|
+
return Shell;
|
|
11713
|
+
}(atma_utils_1.class_EventEmitter));
|
|
11714
|
+
exports.Shell = Shell;
|
|
11715
|
+
;
|
|
11716
|
+
var ProcessResult = /** @class */ (function () {
|
|
11717
|
+
function ProcessResult(options) {
|
|
11718
|
+
this.options = options;
|
|
11719
|
+
this.std = [];
|
|
11720
|
+
this.stdout = [];
|
|
11721
|
+
this.stderr = [];
|
|
11722
|
+
this.resultCode = null;
|
|
11723
|
+
this.error = null;
|
|
11724
|
+
}
|
|
11725
|
+
return ProcessResult;
|
|
11726
|
+
}());
|
|
11727
|
+
exports.ProcessResult = ProcessResult;
|
|
11728
|
+
var ShellState;
|
|
11729
|
+
(function (ShellState) {
|
|
11730
|
+
ShellState[ShellState["Empty"] = -1] = "Empty";
|
|
11731
|
+
ShellState[ShellState["Initial"] = 0] = "Initial";
|
|
11732
|
+
ShellState[ShellState["Started"] = 1] = "Started";
|
|
11733
|
+
})(ShellState || (ShellState = {}));
|
|
11725
11734
|
;
|
|
11726
11735
|
|
|
11727
11736
|
function __isObj(x) {
|
|
@@ -11749,292 +11758,292 @@ var _src_ps_PsList;
|
|
|
11749
11758
|
var exports = _src_ps_PsList != null ? _src_ps_PsList : {};
|
|
11750
11759
|
var module = { exports: exports };
|
|
11751
11760
|
|
|
11752
|
-
"use strict";
|
|
11753
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
11754
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
11755
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
11756
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
11757
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
11758
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
11759
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
11760
|
-
});
|
|
11761
|
-
};
|
|
11762
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11763
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
11764
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
11765
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
11766
|
-
function step(op) {
|
|
11767
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
11768
|
-
while (_) try {
|
|
11769
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
11770
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
11771
|
-
switch (op[0]) {
|
|
11772
|
-
case 0: case 1: t = op; break;
|
|
11773
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
11774
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
11775
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
11776
|
-
default:
|
|
11777
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
11778
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
11779
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
11780
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
11781
|
-
if (t[2]) _.ops.pop();
|
|
11782
|
-
_.trys.pop(); continue;
|
|
11783
|
-
}
|
|
11784
|
-
op = body.call(thisArg, _);
|
|
11785
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
11786
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
11787
|
-
}
|
|
11788
|
-
};
|
|
11789
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11790
|
-
exports.PsList = void 0;
|
|
11791
|
-
var Shell_1 = _src_Shell;
|
|
11792
|
-
var path = require("path");
|
|
11793
|
-
var treeKill = require("tree-kill");
|
|
11794
|
-
var PsList;
|
|
11795
|
-
(function (PsList) {
|
|
11796
|
-
function getAll() {
|
|
11797
|
-
return __awaiter(this, void 0, Promise, function () {
|
|
11798
|
-
return __generator(this, function (_a) {
|
|
11799
|
-
return [2 /*return*/, Platforms[process.platform]()];
|
|
11800
|
-
});
|
|
11801
|
-
});
|
|
11802
|
-
}
|
|
11803
|
-
PsList.getAll = getAll;
|
|
11804
|
-
function kill(pid) {
|
|
11805
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
11806
|
-
return __generator(this, function (_a) {
|
|
11807
|
-
return [2 /*return*/, treeKill(pid)];
|
|
11808
|
-
});
|
|
11809
|
-
});
|
|
11810
|
-
}
|
|
11811
|
-
PsList.kill = kill;
|
|
11812
|
-
var ProcessListResolver = {
|
|
11813
|
-
nix: function () {
|
|
11814
|
-
var _a;
|
|
11815
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
11816
|
-
var shell, stdout, data, columns, list;
|
|
11817
|
-
return __generator(this, function (_b) {
|
|
11818
|
-
switch (_b.label) {
|
|
11819
|
-
case 0: return [4 /*yield*/, Shell_1.Shell.run({
|
|
11820
|
-
silent: true,
|
|
11821
|
-
command: "ps ax -ww -o pid,ppid,uid,gid,args"
|
|
11822
|
-
})];
|
|
11823
|
-
case 1:
|
|
11824
|
-
shell = _b.sent();
|
|
11825
|
-
stdout = (_a = shell.stdout) === null || _a === void 0 ? void 0 : _a.join('');
|
|
11826
|
-
data = utils.stripLine(stdout, 1);
|
|
11827
|
-
columns = utils.extractColumns(data, [0, 1, 2, 3, 4], 5);
|
|
11828
|
-
list = columns.map(function (column) {
|
|
11829
|
-
var cmd = String(column[4]);
|
|
11830
|
-
var bin = fetchBin(cmd);
|
|
11831
|
-
return {
|
|
11832
|
-
pid: parseInt(column[0], 10),
|
|
11833
|
-
ppid: parseInt(column[1], 10),
|
|
11834
|
-
uid: parseInt(column[2], 10),
|
|
11835
|
-
gid: parseInt(column[3], 10),
|
|
11836
|
-
name: fetchName(bin),
|
|
11837
|
-
bin: bin,
|
|
11838
|
-
cmd: column[4]
|
|
11839
|
-
};
|
|
11840
|
-
});
|
|
11841
|
-
return [2 /*return*/, list];
|
|
11842
|
-
}
|
|
11843
|
-
});
|
|
11844
|
-
});
|
|
11845
|
-
},
|
|
11846
|
-
win32: function () {
|
|
11847
|
-
var _a;
|
|
11848
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
11849
|
-
var shell, std, list;
|
|
11850
|
-
return __generator(this, function (_b) {
|
|
11851
|
-
switch (_b.label) {
|
|
11852
|
-
case 0: return [4 /*yield*/, Shell_1.Shell.run({
|
|
11853
|
-
silent: true,
|
|
11854
|
-
command: "powershell.exe /c \"Get-CimInstance -className win32_process | select Name,ProcessId,ParentProcessId,CommandLine,ExecutablePath\"",
|
|
11855
|
-
})];
|
|
11856
|
-
case 1:
|
|
11857
|
-
shell = _b.sent();
|
|
11858
|
-
std = (_a = shell.std) === null || _a === void 0 ? void 0 : _a.join('');
|
|
11859
|
-
list = utils
|
|
11860
|
-
.parseTable(std)
|
|
11861
|
-
.map(function (row) { return ({
|
|
11862
|
-
pid: parseInt(row.ProcessId, 10),
|
|
11863
|
-
ppid: parseInt(row.ParentProcessId, 10),
|
|
11864
|
-
bin: row.ExecutablePath,
|
|
11865
|
-
name: row.Name || '',
|
|
11866
|
-
cmd: row.CommandLine
|
|
11867
|
-
}); });
|
|
11868
|
-
return [2 /*return*/, list];
|
|
11869
|
-
}
|
|
11870
|
-
});
|
|
11871
|
-
});
|
|
11872
|
-
}
|
|
11873
|
-
};
|
|
11874
|
-
var Platforms = {
|
|
11875
|
-
darwin: ProcessListResolver.nix,
|
|
11876
|
-
linux: ProcessListResolver.nix,
|
|
11877
|
-
sunos: ProcessListResolver.nix,
|
|
11878
|
-
freebsd: ProcessListResolver.nix,
|
|
11879
|
-
win32: ProcessListResolver.win32,
|
|
11880
|
-
};
|
|
11881
|
-
function fetchBin(cmd) {
|
|
11882
|
-
var pieces = cmd.split(path.sep);
|
|
11883
|
-
var last = pieces[pieces.length - 1];
|
|
11884
|
-
if (last) {
|
|
11885
|
-
pieces[pieces.length - 1] = last.split(' ')[0];
|
|
11886
|
-
}
|
|
11887
|
-
var fixed = [];
|
|
11888
|
-
for (var _i = 0, pieces_1 = pieces; _i < pieces_1.length; _i++) {
|
|
11889
|
-
var part = pieces_1[_i];
|
|
11890
|
-
var optIdx = part.indexOf(' -');
|
|
11891
|
-
if (optIdx >= 0) {
|
|
11892
|
-
// case: /aaa/bbb/ccc -c
|
|
11893
|
-
fixed.push(part.substring(0, optIdx).trim());
|
|
11894
|
-
break;
|
|
11895
|
-
}
|
|
11896
|
-
else if (part.endsWith(' ')) {
|
|
11897
|
-
// case: node /aaa/bbb/ccc.js
|
|
11898
|
-
fixed.push(part.trim());
|
|
11899
|
-
break;
|
|
11900
|
-
}
|
|
11901
|
-
fixed.push(part);
|
|
11902
|
-
}
|
|
11903
|
-
return fixed.join(path.sep);
|
|
11904
|
-
}
|
|
11905
|
-
function fetchName(fullpath) {
|
|
11906
|
-
if (process.platform === 'darwin') {
|
|
11907
|
-
var idx = fullpath.indexOf('.app/');
|
|
11908
|
-
if (idx >= 0) {
|
|
11909
|
-
return path.basename(fullpath.substring(0, idx));
|
|
11910
|
-
}
|
|
11911
|
-
}
|
|
11912
|
-
return path.basename(fullpath);
|
|
11913
|
-
}
|
|
11914
|
-
var utils = {
|
|
11915
|
-
/**
|
|
11916
|
-
* Strip top lines of text
|
|
11917
|
-
*
|
|
11918
|
-
* @param {String} text
|
|
11919
|
-
* @param {Number} num
|
|
11920
|
-
* @return {String}
|
|
11921
|
-
*/
|
|
11922
|
-
stripLine: function (text, num) {
|
|
11923
|
-
var idx = 0;
|
|
11924
|
-
while (num-- > 0) {
|
|
11925
|
-
var nIdx = text.indexOf('\n', idx);
|
|
11926
|
-
if (nIdx >= 0) {
|
|
11927
|
-
idx = nIdx + 1;
|
|
11928
|
-
}
|
|
11929
|
-
}
|
|
11930
|
-
return idx > 0 ? text.substring(idx) : text;
|
|
11931
|
-
},
|
|
11932
|
-
/**
|
|
11933
|
-
* Split string and stop at max parts
|
|
11934
|
-
*
|
|
11935
|
-
* @param {Number} line
|
|
11936
|
-
* @param {Number} max
|
|
11937
|
-
* @return {Array}
|
|
11938
|
-
*/
|
|
11939
|
-
split: function (line, max) {
|
|
11940
|
-
var cols = line.trim().split(/\s+/);
|
|
11941
|
-
if (cols.length > max) {
|
|
11942
|
-
cols[max - 1] = cols.slice(max - 1).join(' ');
|
|
11943
|
-
}
|
|
11944
|
-
return cols;
|
|
11945
|
-
},
|
|
11946
|
-
/**
|
|
11947
|
-
* Extract columns from table text
|
|
11948
|
-
*
|
|
11949
|
-
* Example:
|
|
11950
|
-
*
|
|
11951
|
-
* ```
|
|
11952
|
-
* extractColumns(text, [0, 2], 3)
|
|
11953
|
-
* ```
|
|
11954
|
-
*
|
|
11955
|
-
* From:
|
|
11956
|
-
* ```
|
|
11957
|
-
* foo bar bar2
|
|
11958
|
-
* valx valy valz
|
|
11959
|
-
* ```
|
|
11960
|
-
*
|
|
11961
|
-
* To:
|
|
11962
|
-
* ```
|
|
11963
|
-
* [ ['foo', 'bar2'], ['valx', 'valz'] ]
|
|
11964
|
-
* ```
|
|
11965
|
-
*
|
|
11966
|
-
* @param {String} text raw table text
|
|
11967
|
-
* @param {Array} idxes the column index list to extract
|
|
11968
|
-
* @param {Number} max max column number of table
|
|
11969
|
-
* @return {Array}
|
|
11970
|
-
*/
|
|
11971
|
-
extractColumns: function (text, idxes, max) {
|
|
11972
|
-
var lines = text.split(/(\r\n|\n|\r)/);
|
|
11973
|
-
var columns = [];
|
|
11974
|
-
if (!max) {
|
|
11975
|
-
max = Math.max.apply(null, idxes) + 1;
|
|
11976
|
-
}
|
|
11977
|
-
lines.forEach(function (line) {
|
|
11978
|
-
var cols = utils.split(line, max);
|
|
11979
|
-
var column = [];
|
|
11980
|
-
idxes.forEach(function (idx) {
|
|
11981
|
-
column.push(cols[idx] || '');
|
|
11982
|
-
});
|
|
11983
|
-
columns.push(column);
|
|
11984
|
-
});
|
|
11985
|
-
return columns;
|
|
11986
|
-
},
|
|
11987
|
-
/**
|
|
11988
|
-
* parse table text to array
|
|
11989
|
-
*
|
|
11990
|
-
* From:
|
|
11991
|
-
* ```
|
|
11992
|
-
* Header1 : foo
|
|
11993
|
-
* Header2 : bar
|
|
11994
|
-
* Header3 : val
|
|
11995
|
-
*
|
|
11996
|
-
* Header1 : foo2
|
|
11997
|
-
* Header2 : bar2
|
|
11998
|
-
* Header3 : val2
|
|
11999
|
-
* ```
|
|
12000
|
-
*
|
|
12001
|
-
* To:
|
|
12002
|
-
* ```
|
|
12003
|
-
* [{ Header1: 'foo', Header2: 'bar', Header3: 'val' }, ...]
|
|
12004
|
-
* ```
|
|
12005
|
-
*
|
|
12006
|
-
* @param {String} data raw table data
|
|
12007
|
-
* @return {Array}
|
|
12008
|
-
*/
|
|
12009
|
-
parseTable: function (data) {
|
|
12010
|
-
var lines = data.split(/(\r\n\r\n|\r\n\n|\n\r\n)|\n\n/).filter(function (line) {
|
|
12011
|
-
return line.trim().length > 0;
|
|
12012
|
-
}).map(function (e) { return e.split(/(\r\n|\n|\r)/).filter(function (line) { return line.trim().length > 0; }); });
|
|
12013
|
-
// Join multi-ligne value
|
|
12014
|
-
lines.forEach(function (line) {
|
|
12015
|
-
for (var index = 0; line[index];) {
|
|
12016
|
-
var entry = line[index];
|
|
12017
|
-
if (entry.startsWith(' ')) {
|
|
12018
|
-
line[index - 1] += entry.trimLeft();
|
|
12019
|
-
line.splice(index, 1);
|
|
12020
|
-
}
|
|
12021
|
-
else {
|
|
12022
|
-
index += 1;
|
|
12023
|
-
}
|
|
12024
|
-
}
|
|
12025
|
-
});
|
|
12026
|
-
return lines.map(function (line) {
|
|
12027
|
-
var row = {};
|
|
12028
|
-
line.forEach(function (string) {
|
|
12029
|
-
var splitterIndex = string.indexOf(':');
|
|
12030
|
-
var key = string.slice(0, splitterIndex).trim();
|
|
12031
|
-
row[key] = string.slice(splitterIndex + 1).trim();
|
|
12032
|
-
});
|
|
12033
|
-
return row;
|
|
12034
|
-
});
|
|
12035
|
-
}
|
|
12036
|
-
};
|
|
12037
|
-
})(PsList = exports.PsList || (exports.PsList = {}));
|
|
11761
|
+
"use strict";
|
|
11762
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
11763
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
11764
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
11765
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
11766
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
11767
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
11768
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
11769
|
+
});
|
|
11770
|
+
};
|
|
11771
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11772
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
11773
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
11774
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
11775
|
+
function step(op) {
|
|
11776
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
11777
|
+
while (_) try {
|
|
11778
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
11779
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
11780
|
+
switch (op[0]) {
|
|
11781
|
+
case 0: case 1: t = op; break;
|
|
11782
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
11783
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
11784
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
11785
|
+
default:
|
|
11786
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
11787
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
11788
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
11789
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
11790
|
+
if (t[2]) _.ops.pop();
|
|
11791
|
+
_.trys.pop(); continue;
|
|
11792
|
+
}
|
|
11793
|
+
op = body.call(thisArg, _);
|
|
11794
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
11795
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
11796
|
+
}
|
|
11797
|
+
};
|
|
11798
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11799
|
+
exports.PsList = void 0;
|
|
11800
|
+
var Shell_1 = _src_Shell;
|
|
11801
|
+
var path = require("path");
|
|
11802
|
+
var treeKill = require("tree-kill");
|
|
11803
|
+
var PsList;
|
|
11804
|
+
(function (PsList) {
|
|
11805
|
+
function getAll() {
|
|
11806
|
+
return __awaiter(this, void 0, Promise, function () {
|
|
11807
|
+
return __generator(this, function (_a) {
|
|
11808
|
+
return [2 /*return*/, Platforms[process.platform]()];
|
|
11809
|
+
});
|
|
11810
|
+
});
|
|
11811
|
+
}
|
|
11812
|
+
PsList.getAll = getAll;
|
|
11813
|
+
function kill(pid) {
|
|
11814
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
11815
|
+
return __generator(this, function (_a) {
|
|
11816
|
+
return [2 /*return*/, treeKill(pid)];
|
|
11817
|
+
});
|
|
11818
|
+
});
|
|
11819
|
+
}
|
|
11820
|
+
PsList.kill = kill;
|
|
11821
|
+
var ProcessListResolver = {
|
|
11822
|
+
nix: function () {
|
|
11823
|
+
var _a;
|
|
11824
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
11825
|
+
var shell, stdout, data, columns, list;
|
|
11826
|
+
return __generator(this, function (_b) {
|
|
11827
|
+
switch (_b.label) {
|
|
11828
|
+
case 0: return [4 /*yield*/, Shell_1.Shell.run({
|
|
11829
|
+
silent: true,
|
|
11830
|
+
command: "ps ax -ww -o pid,ppid,uid,gid,args"
|
|
11831
|
+
})];
|
|
11832
|
+
case 1:
|
|
11833
|
+
shell = _b.sent();
|
|
11834
|
+
stdout = (_a = shell.stdout) === null || _a === void 0 ? void 0 : _a.join('');
|
|
11835
|
+
data = utils.stripLine(stdout, 1);
|
|
11836
|
+
columns = utils.extractColumns(data, [0, 1, 2, 3, 4], 5);
|
|
11837
|
+
list = columns.map(function (column) {
|
|
11838
|
+
var cmd = String(column[4]);
|
|
11839
|
+
var bin = fetchBin(cmd);
|
|
11840
|
+
return {
|
|
11841
|
+
pid: parseInt(column[0], 10),
|
|
11842
|
+
ppid: parseInt(column[1], 10),
|
|
11843
|
+
uid: parseInt(column[2], 10),
|
|
11844
|
+
gid: parseInt(column[3], 10),
|
|
11845
|
+
name: fetchName(bin),
|
|
11846
|
+
bin: bin,
|
|
11847
|
+
cmd: column[4]
|
|
11848
|
+
};
|
|
11849
|
+
});
|
|
11850
|
+
return [2 /*return*/, list];
|
|
11851
|
+
}
|
|
11852
|
+
});
|
|
11853
|
+
});
|
|
11854
|
+
},
|
|
11855
|
+
win32: function () {
|
|
11856
|
+
var _a;
|
|
11857
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
11858
|
+
var shell, std, list;
|
|
11859
|
+
return __generator(this, function (_b) {
|
|
11860
|
+
switch (_b.label) {
|
|
11861
|
+
case 0: return [4 /*yield*/, Shell_1.Shell.run({
|
|
11862
|
+
silent: true,
|
|
11863
|
+
command: "powershell.exe /c \"Get-CimInstance -className win32_process | select Name,ProcessId,ParentProcessId,CommandLine,ExecutablePath\"",
|
|
11864
|
+
})];
|
|
11865
|
+
case 1:
|
|
11866
|
+
shell = _b.sent();
|
|
11867
|
+
std = (_a = shell.std) === null || _a === void 0 ? void 0 : _a.join('');
|
|
11868
|
+
list = utils
|
|
11869
|
+
.parseTable(std)
|
|
11870
|
+
.map(function (row) { return ({
|
|
11871
|
+
pid: parseInt(row.ProcessId, 10),
|
|
11872
|
+
ppid: parseInt(row.ParentProcessId, 10),
|
|
11873
|
+
bin: row.ExecutablePath,
|
|
11874
|
+
name: row.Name || '',
|
|
11875
|
+
cmd: row.CommandLine
|
|
11876
|
+
}); });
|
|
11877
|
+
return [2 /*return*/, list];
|
|
11878
|
+
}
|
|
11879
|
+
});
|
|
11880
|
+
});
|
|
11881
|
+
}
|
|
11882
|
+
};
|
|
11883
|
+
var Platforms = {
|
|
11884
|
+
darwin: ProcessListResolver.nix,
|
|
11885
|
+
linux: ProcessListResolver.nix,
|
|
11886
|
+
sunos: ProcessListResolver.nix,
|
|
11887
|
+
freebsd: ProcessListResolver.nix,
|
|
11888
|
+
win32: ProcessListResolver.win32,
|
|
11889
|
+
};
|
|
11890
|
+
function fetchBin(cmd) {
|
|
11891
|
+
var pieces = cmd.split(path.sep);
|
|
11892
|
+
var last = pieces[pieces.length - 1];
|
|
11893
|
+
if (last) {
|
|
11894
|
+
pieces[pieces.length - 1] = last.split(' ')[0];
|
|
11895
|
+
}
|
|
11896
|
+
var fixed = [];
|
|
11897
|
+
for (var _i = 0, pieces_1 = pieces; _i < pieces_1.length; _i++) {
|
|
11898
|
+
var part = pieces_1[_i];
|
|
11899
|
+
var optIdx = part.indexOf(' -');
|
|
11900
|
+
if (optIdx >= 0) {
|
|
11901
|
+
// case: /aaa/bbb/ccc -c
|
|
11902
|
+
fixed.push(part.substring(0, optIdx).trim());
|
|
11903
|
+
break;
|
|
11904
|
+
}
|
|
11905
|
+
else if (part.endsWith(' ')) {
|
|
11906
|
+
// case: node /aaa/bbb/ccc.js
|
|
11907
|
+
fixed.push(part.trim());
|
|
11908
|
+
break;
|
|
11909
|
+
}
|
|
11910
|
+
fixed.push(part);
|
|
11911
|
+
}
|
|
11912
|
+
return fixed.join(path.sep);
|
|
11913
|
+
}
|
|
11914
|
+
function fetchName(fullpath) {
|
|
11915
|
+
if (process.platform === 'darwin') {
|
|
11916
|
+
var idx = fullpath.indexOf('.app/');
|
|
11917
|
+
if (idx >= 0) {
|
|
11918
|
+
return path.basename(fullpath.substring(0, idx));
|
|
11919
|
+
}
|
|
11920
|
+
}
|
|
11921
|
+
return path.basename(fullpath);
|
|
11922
|
+
}
|
|
11923
|
+
var utils = {
|
|
11924
|
+
/**
|
|
11925
|
+
* Strip top lines of text
|
|
11926
|
+
*
|
|
11927
|
+
* @param {String} text
|
|
11928
|
+
* @param {Number} num
|
|
11929
|
+
* @return {String}
|
|
11930
|
+
*/
|
|
11931
|
+
stripLine: function (text, num) {
|
|
11932
|
+
var idx = 0;
|
|
11933
|
+
while (num-- > 0) {
|
|
11934
|
+
var nIdx = text.indexOf('\n', idx);
|
|
11935
|
+
if (nIdx >= 0) {
|
|
11936
|
+
idx = nIdx + 1;
|
|
11937
|
+
}
|
|
11938
|
+
}
|
|
11939
|
+
return idx > 0 ? text.substring(idx) : text;
|
|
11940
|
+
},
|
|
11941
|
+
/**
|
|
11942
|
+
* Split string and stop at max parts
|
|
11943
|
+
*
|
|
11944
|
+
* @param {Number} line
|
|
11945
|
+
* @param {Number} max
|
|
11946
|
+
* @return {Array}
|
|
11947
|
+
*/
|
|
11948
|
+
split: function (line, max) {
|
|
11949
|
+
var cols = line.trim().split(/\s+/);
|
|
11950
|
+
if (cols.length > max) {
|
|
11951
|
+
cols[max - 1] = cols.slice(max - 1).join(' ');
|
|
11952
|
+
}
|
|
11953
|
+
return cols;
|
|
11954
|
+
},
|
|
11955
|
+
/**
|
|
11956
|
+
* Extract columns from table text
|
|
11957
|
+
*
|
|
11958
|
+
* Example:
|
|
11959
|
+
*
|
|
11960
|
+
* ```
|
|
11961
|
+
* extractColumns(text, [0, 2], 3)
|
|
11962
|
+
* ```
|
|
11963
|
+
*
|
|
11964
|
+
* From:
|
|
11965
|
+
* ```
|
|
11966
|
+
* foo bar bar2
|
|
11967
|
+
* valx valy valz
|
|
11968
|
+
* ```
|
|
11969
|
+
*
|
|
11970
|
+
* To:
|
|
11971
|
+
* ```
|
|
11972
|
+
* [ ['foo', 'bar2'], ['valx', 'valz'] ]
|
|
11973
|
+
* ```
|
|
11974
|
+
*
|
|
11975
|
+
* @param {String} text raw table text
|
|
11976
|
+
* @param {Array} idxes the column index list to extract
|
|
11977
|
+
* @param {Number} max max column number of table
|
|
11978
|
+
* @return {Array}
|
|
11979
|
+
*/
|
|
11980
|
+
extractColumns: function (text, idxes, max) {
|
|
11981
|
+
var lines = text.split(/(\r\n|\n|\r)/);
|
|
11982
|
+
var columns = [];
|
|
11983
|
+
if (!max) {
|
|
11984
|
+
max = Math.max.apply(null, idxes) + 1;
|
|
11985
|
+
}
|
|
11986
|
+
lines.forEach(function (line) {
|
|
11987
|
+
var cols = utils.split(line, max);
|
|
11988
|
+
var column = [];
|
|
11989
|
+
idxes.forEach(function (idx) {
|
|
11990
|
+
column.push(cols[idx] || '');
|
|
11991
|
+
});
|
|
11992
|
+
columns.push(column);
|
|
11993
|
+
});
|
|
11994
|
+
return columns;
|
|
11995
|
+
},
|
|
11996
|
+
/**
|
|
11997
|
+
* parse table text to array
|
|
11998
|
+
*
|
|
11999
|
+
* From:
|
|
12000
|
+
* ```
|
|
12001
|
+
* Header1 : foo
|
|
12002
|
+
* Header2 : bar
|
|
12003
|
+
* Header3 : val
|
|
12004
|
+
*
|
|
12005
|
+
* Header1 : foo2
|
|
12006
|
+
* Header2 : bar2
|
|
12007
|
+
* Header3 : val2
|
|
12008
|
+
* ```
|
|
12009
|
+
*
|
|
12010
|
+
* To:
|
|
12011
|
+
* ```
|
|
12012
|
+
* [{ Header1: 'foo', Header2: 'bar', Header3: 'val' }, ...]
|
|
12013
|
+
* ```
|
|
12014
|
+
*
|
|
12015
|
+
* @param {String} data raw table data
|
|
12016
|
+
* @return {Array}
|
|
12017
|
+
*/
|
|
12018
|
+
parseTable: function (data) {
|
|
12019
|
+
var lines = data.split(/(\r\n\r\n|\r\n\n|\n\r\n)|\n\n/).filter(function (line) {
|
|
12020
|
+
return line.trim().length > 0;
|
|
12021
|
+
}).map(function (e) { return e.split(/(\r\n|\n|\r)/).filter(function (line) { return line.trim().length > 0; }); });
|
|
12022
|
+
// Join multi-ligne value
|
|
12023
|
+
lines.forEach(function (line) {
|
|
12024
|
+
for (var index = 0; line[index];) {
|
|
12025
|
+
var entry = line[index];
|
|
12026
|
+
if (entry.startsWith(' ')) {
|
|
12027
|
+
line[index - 1] += entry.trimLeft();
|
|
12028
|
+
line.splice(index, 1);
|
|
12029
|
+
}
|
|
12030
|
+
else {
|
|
12031
|
+
index += 1;
|
|
12032
|
+
}
|
|
12033
|
+
}
|
|
12034
|
+
});
|
|
12035
|
+
return lines.map(function (line) {
|
|
12036
|
+
var row = {};
|
|
12037
|
+
line.forEach(function (string) {
|
|
12038
|
+
var splitterIndex = string.indexOf(':');
|
|
12039
|
+
var key = string.slice(0, splitterIndex).trim();
|
|
12040
|
+
row[key] = string.slice(splitterIndex + 1).trim();
|
|
12041
|
+
});
|
|
12042
|
+
return row;
|
|
12043
|
+
});
|
|
12044
|
+
}
|
|
12045
|
+
};
|
|
12046
|
+
})(PsList = exports.PsList || (exports.PsList = {}));
|
|
12038
12047
|
;
|
|
12039
12048
|
|
|
12040
12049
|
function __isObj(x) {
|
|
@@ -12062,185 +12071,185 @@ var _src_ps_Net;
|
|
|
12062
12071
|
var exports = _src_ps_Net != null ? _src_ps_Net : {};
|
|
12063
12072
|
var module = { exports: exports };
|
|
12064
12073
|
|
|
12065
|
-
"use strict";
|
|
12066
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
12067
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
12068
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
12069
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
12070
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
12071
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
12072
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
12073
|
-
});
|
|
12074
|
-
};
|
|
12075
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12076
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12077
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
12078
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
12079
|
-
function step(op) {
|
|
12080
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
12081
|
-
while (_) try {
|
|
12082
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
12083
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
12084
|
-
switch (op[0]) {
|
|
12085
|
-
case 0: case 1: t = op; break;
|
|
12086
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
12087
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
12088
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
12089
|
-
default:
|
|
12090
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
12091
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
12092
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
12093
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
12094
|
-
if (t[2]) _.ops.pop();
|
|
12095
|
-
_.trys.pop(); continue;
|
|
12096
|
-
}
|
|
12097
|
-
op = body.call(thisArg, _);
|
|
12098
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
12099
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
12100
|
-
}
|
|
12101
|
-
};
|
|
12102
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12103
|
-
exports.Net = void 0;
|
|
12104
|
-
var alot_1 = require("alot");
|
|
12105
|
-
var Shell_1 = _src_Shell;
|
|
12106
|
-
var PsList_1 = _src_ps_PsList;
|
|
12107
|
-
var Net;
|
|
12108
|
-
(function (Net) {
|
|
12109
|
-
var PidResolver = {
|
|
12110
|
-
nix: function (port) {
|
|
12111
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
12112
|
-
var table, iPid, iStatus, iProtocol;
|
|
12113
|
-
return __generator(this, function (_a) {
|
|
12114
|
-
switch (_a.label) {
|
|
12115
|
-
case 0: return [4 /*yield*/, exec("lsof -i :".concat(port))];
|
|
12116
|
-
case 1:
|
|
12117
|
-
table = _a.sent();
|
|
12118
|
-
iPid = 1;
|
|
12119
|
-
iStatus = 9;
|
|
12120
|
-
iProtocol = 7;
|
|
12121
|
-
return [2 /*return*/, table.map(function (row) {
|
|
12122
|
-
var _a, _b, _c;
|
|
12123
|
-
var pid = Number(row[iPid]);
|
|
12124
|
-
var status = (_a = row[iStatus]) !== null && _a !== void 0 ? _a : '';
|
|
12125
|
-
var protocol = (_c = (_b = row[iProtocol]) === null || _b === void 0 ? void 0 : _b.toLowerCase()) !== null && _c !== void 0 ? _c : 'tcp';
|
|
12126
|
-
return {
|
|
12127
|
-
pid: pid,
|
|
12128
|
-
status: status,
|
|
12129
|
-
protocol: protocol,
|
|
12130
|
-
};
|
|
12131
|
-
})];
|
|
12132
|
-
}
|
|
12133
|
-
});
|
|
12134
|
-
});
|
|
12135
|
-
},
|
|
12136
|
-
win32: function (port) {
|
|
12137
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
12138
|
-
var table, iPid, iStatus, iProtocol;
|
|
12139
|
-
return __generator(this, function (_a) {
|
|
12140
|
-
switch (_a.label) {
|
|
12141
|
-
case 0: return [4 /*yield*/, exec("netstat -a -n -o | findstr :".concat(port))];
|
|
12142
|
-
case 1:
|
|
12143
|
-
table = _a.sent();
|
|
12144
|
-
iPid = 4;
|
|
12145
|
-
iStatus = 3;
|
|
12146
|
-
iProtocol = 0;
|
|
12147
|
-
return [2 /*return*/, table.map(function (row) {
|
|
12148
|
-
var _a;
|
|
12149
|
-
var pid = Number(row[iPid]);
|
|
12150
|
-
var status = row[iStatus];
|
|
12151
|
-
var protocol = (_a = row[iProtocol]) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
|
12152
|
-
return {
|
|
12153
|
-
pid: pid,
|
|
12154
|
-
status: status,
|
|
12155
|
-
protocol: protocol,
|
|
12156
|
-
};
|
|
12157
|
-
})];
|
|
12158
|
-
}
|
|
12159
|
-
});
|
|
12160
|
-
});
|
|
12161
|
-
}
|
|
12162
|
-
};
|
|
12163
|
-
function exec(command) {
|
|
12164
|
-
var _a;
|
|
12165
|
-
return __awaiter(this, void 0, Promise, function () {
|
|
12166
|
-
var shell, std;
|
|
12167
|
-
return __generator(this, function (_b) {
|
|
12168
|
-
switch (_b.label) {
|
|
12169
|
-
case 0: return [4 /*yield*/, Shell_1.Shell.run({
|
|
12170
|
-
silent: true,
|
|
12171
|
-
command: command,
|
|
12172
|
-
})];
|
|
12173
|
-
case 1:
|
|
12174
|
-
shell = _b.sent();
|
|
12175
|
-
std = (_a = shell.std) === null || _a === void 0 ? void 0 : _a.join('');
|
|
12176
|
-
return [2 /*return*/, std
|
|
12177
|
-
.split('\n')
|
|
12178
|
-
.map(function (x) { return x.trim(); })
|
|
12179
|
-
.filter(Boolean)
|
|
12180
|
-
.map(function (line) {
|
|
12181
|
-
return line.split(' ').map(function (x) { return x.trim(); }).filter(Boolean);
|
|
12182
|
-
})
|
|
12183
|
-
.filter(function (x) { return x.length > 0; })];
|
|
12184
|
-
}
|
|
12185
|
-
});
|
|
12186
|
-
});
|
|
12187
|
-
}
|
|
12188
|
-
var Platforms = {
|
|
12189
|
-
darwin: PidResolver.nix,
|
|
12190
|
-
linux: PidResolver.nix,
|
|
12191
|
-
sunos: PidResolver.nix,
|
|
12192
|
-
freebsd: PidResolver.nix,
|
|
12193
|
-
win32: PidResolver.win32,
|
|
12194
|
-
};
|
|
12195
|
-
function findByPort(port) {
|
|
12196
|
-
return __awaiter(this, void 0, Promise, function () {
|
|
12197
|
-
var arr;
|
|
12198
|
-
return __generator(this, function (_a) {
|
|
12199
|
-
switch (_a.label) {
|
|
12200
|
-
case 0: return [4 /*yield*/, Platforms[process.platform](port)];
|
|
12201
|
-
case 1:
|
|
12202
|
-
arr = _a.sent();
|
|
12203
|
-
return [2 /*return*/, (0, alot_1.default)(arr)
|
|
12204
|
-
.filter(function (x) { return Boolean(x.pid); })
|
|
12205
|
-
.distinctBy(function (x) { return x.pid; })
|
|
12206
|
-
.toArray()];
|
|
12207
|
-
}
|
|
12208
|
-
});
|
|
12209
|
-
});
|
|
12210
|
-
}
|
|
12211
|
-
Net.findByPort = findByPort;
|
|
12212
|
-
;
|
|
12213
|
-
function killByPort(port) {
|
|
12214
|
-
return __awaiter(this, void 0, Promise, function () {
|
|
12215
|
-
var processes;
|
|
12216
|
-
var _this = this;
|
|
12217
|
-
return __generator(this, function (_a) {
|
|
12218
|
-
switch (_a.label) {
|
|
12219
|
-
case 0: return [4 /*yield*/, findByPort(port)];
|
|
12220
|
-
case 1:
|
|
12221
|
-
processes = _a.sent();
|
|
12222
|
-
return [4 /*yield*/, (0, alot_1.default)(processes).forEachAsync(function (x) { return __awaiter(_this, void 0, void 0, function () {
|
|
12223
|
-
return __generator(this, function (_a) {
|
|
12224
|
-
switch (_a.label) {
|
|
12225
|
-
case 0:
|
|
12226
|
-
if (!x.pid) return [3 /*break*/, 2];
|
|
12227
|
-
return [4 /*yield*/, PsList_1.PsList.kill(x.pid)];
|
|
12228
|
-
case 1:
|
|
12229
|
-
_a.sent();
|
|
12230
|
-
_a.label = 2;
|
|
12231
|
-
case 2: return [2 /*return*/];
|
|
12232
|
-
}
|
|
12233
|
-
});
|
|
12234
|
-
}); }).toArrayAsync()];
|
|
12235
|
-
case 2:
|
|
12236
|
-
_a.sent();
|
|
12237
|
-
return [2 /*return*/, processes];
|
|
12238
|
-
}
|
|
12239
|
-
});
|
|
12240
|
-
});
|
|
12241
|
-
}
|
|
12242
|
-
Net.killByPort = killByPort;
|
|
12243
|
-
})(Net = exports.Net || (exports.Net = {}));
|
|
12074
|
+
"use strict";
|
|
12075
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
12076
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
12077
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
12078
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
12079
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
12080
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
12081
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
12082
|
+
});
|
|
12083
|
+
};
|
|
12084
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12085
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12086
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
12087
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
12088
|
+
function step(op) {
|
|
12089
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
12090
|
+
while (_) try {
|
|
12091
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
12092
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
12093
|
+
switch (op[0]) {
|
|
12094
|
+
case 0: case 1: t = op; break;
|
|
12095
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
12096
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
12097
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
12098
|
+
default:
|
|
12099
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
12100
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
12101
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
12102
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
12103
|
+
if (t[2]) _.ops.pop();
|
|
12104
|
+
_.trys.pop(); continue;
|
|
12105
|
+
}
|
|
12106
|
+
op = body.call(thisArg, _);
|
|
12107
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
12108
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
12109
|
+
}
|
|
12110
|
+
};
|
|
12111
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12112
|
+
exports.Net = void 0;
|
|
12113
|
+
var alot_1 = require("alot");
|
|
12114
|
+
var Shell_1 = _src_Shell;
|
|
12115
|
+
var PsList_1 = _src_ps_PsList;
|
|
12116
|
+
var Net;
|
|
12117
|
+
(function (Net) {
|
|
12118
|
+
var PidResolver = {
|
|
12119
|
+
nix: function (port) {
|
|
12120
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
12121
|
+
var table, iPid, iStatus, iProtocol;
|
|
12122
|
+
return __generator(this, function (_a) {
|
|
12123
|
+
switch (_a.label) {
|
|
12124
|
+
case 0: return [4 /*yield*/, exec("lsof -i :".concat(port))];
|
|
12125
|
+
case 1:
|
|
12126
|
+
table = _a.sent();
|
|
12127
|
+
iPid = 1;
|
|
12128
|
+
iStatus = 9;
|
|
12129
|
+
iProtocol = 7;
|
|
12130
|
+
return [2 /*return*/, table.map(function (row) {
|
|
12131
|
+
var _a, _b, _c;
|
|
12132
|
+
var pid = Number(row[iPid]);
|
|
12133
|
+
var status = (_a = row[iStatus]) !== null && _a !== void 0 ? _a : '';
|
|
12134
|
+
var protocol = (_c = (_b = row[iProtocol]) === null || _b === void 0 ? void 0 : _b.toLowerCase()) !== null && _c !== void 0 ? _c : 'tcp';
|
|
12135
|
+
return {
|
|
12136
|
+
pid: pid,
|
|
12137
|
+
status: status,
|
|
12138
|
+
protocol: protocol,
|
|
12139
|
+
};
|
|
12140
|
+
})];
|
|
12141
|
+
}
|
|
12142
|
+
});
|
|
12143
|
+
});
|
|
12144
|
+
},
|
|
12145
|
+
win32: function (port) {
|
|
12146
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
12147
|
+
var table, iPid, iStatus, iProtocol;
|
|
12148
|
+
return __generator(this, function (_a) {
|
|
12149
|
+
switch (_a.label) {
|
|
12150
|
+
case 0: return [4 /*yield*/, exec("netstat -a -n -o | findstr :".concat(port))];
|
|
12151
|
+
case 1:
|
|
12152
|
+
table = _a.sent();
|
|
12153
|
+
iPid = 4;
|
|
12154
|
+
iStatus = 3;
|
|
12155
|
+
iProtocol = 0;
|
|
12156
|
+
return [2 /*return*/, table.map(function (row) {
|
|
12157
|
+
var _a;
|
|
12158
|
+
var pid = Number(row[iPid]);
|
|
12159
|
+
var status = row[iStatus];
|
|
12160
|
+
var protocol = (_a = row[iProtocol]) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
|
12161
|
+
return {
|
|
12162
|
+
pid: pid,
|
|
12163
|
+
status: status,
|
|
12164
|
+
protocol: protocol,
|
|
12165
|
+
};
|
|
12166
|
+
})];
|
|
12167
|
+
}
|
|
12168
|
+
});
|
|
12169
|
+
});
|
|
12170
|
+
}
|
|
12171
|
+
};
|
|
12172
|
+
function exec(command) {
|
|
12173
|
+
var _a;
|
|
12174
|
+
return __awaiter(this, void 0, Promise, function () {
|
|
12175
|
+
var shell, std;
|
|
12176
|
+
return __generator(this, function (_b) {
|
|
12177
|
+
switch (_b.label) {
|
|
12178
|
+
case 0: return [4 /*yield*/, Shell_1.Shell.run({
|
|
12179
|
+
silent: true,
|
|
12180
|
+
command: command,
|
|
12181
|
+
})];
|
|
12182
|
+
case 1:
|
|
12183
|
+
shell = _b.sent();
|
|
12184
|
+
std = (_a = shell.std) === null || _a === void 0 ? void 0 : _a.join('');
|
|
12185
|
+
return [2 /*return*/, std
|
|
12186
|
+
.split('\n')
|
|
12187
|
+
.map(function (x) { return x.trim(); })
|
|
12188
|
+
.filter(Boolean)
|
|
12189
|
+
.map(function (line) {
|
|
12190
|
+
return line.split(' ').map(function (x) { return x.trim(); }).filter(Boolean);
|
|
12191
|
+
})
|
|
12192
|
+
.filter(function (x) { return x.length > 0; })];
|
|
12193
|
+
}
|
|
12194
|
+
});
|
|
12195
|
+
});
|
|
12196
|
+
}
|
|
12197
|
+
var Platforms = {
|
|
12198
|
+
darwin: PidResolver.nix,
|
|
12199
|
+
linux: PidResolver.nix,
|
|
12200
|
+
sunos: PidResolver.nix,
|
|
12201
|
+
freebsd: PidResolver.nix,
|
|
12202
|
+
win32: PidResolver.win32,
|
|
12203
|
+
};
|
|
12204
|
+
function findByPort(port) {
|
|
12205
|
+
return __awaiter(this, void 0, Promise, function () {
|
|
12206
|
+
var arr;
|
|
12207
|
+
return __generator(this, function (_a) {
|
|
12208
|
+
switch (_a.label) {
|
|
12209
|
+
case 0: return [4 /*yield*/, Platforms[process.platform](port)];
|
|
12210
|
+
case 1:
|
|
12211
|
+
arr = _a.sent();
|
|
12212
|
+
return [2 /*return*/, (0, alot_1.default)(arr)
|
|
12213
|
+
.filter(function (x) { return Boolean(x.pid); })
|
|
12214
|
+
.distinctBy(function (x) { return x.pid; })
|
|
12215
|
+
.toArray()];
|
|
12216
|
+
}
|
|
12217
|
+
});
|
|
12218
|
+
});
|
|
12219
|
+
}
|
|
12220
|
+
Net.findByPort = findByPort;
|
|
12221
|
+
;
|
|
12222
|
+
function killByPort(port) {
|
|
12223
|
+
return __awaiter(this, void 0, Promise, function () {
|
|
12224
|
+
var processes;
|
|
12225
|
+
var _this = this;
|
|
12226
|
+
return __generator(this, function (_a) {
|
|
12227
|
+
switch (_a.label) {
|
|
12228
|
+
case 0: return [4 /*yield*/, findByPort(port)];
|
|
12229
|
+
case 1:
|
|
12230
|
+
processes = _a.sent();
|
|
12231
|
+
return [4 /*yield*/, (0, alot_1.default)(processes).forEachAsync(function (x) { return __awaiter(_this, void 0, void 0, function () {
|
|
12232
|
+
return __generator(this, function (_a) {
|
|
12233
|
+
switch (_a.label) {
|
|
12234
|
+
case 0:
|
|
12235
|
+
if (!x.pid) return [3 /*break*/, 2];
|
|
12236
|
+
return [4 /*yield*/, PsList_1.PsList.kill(x.pid)];
|
|
12237
|
+
case 1:
|
|
12238
|
+
_a.sent();
|
|
12239
|
+
_a.label = 2;
|
|
12240
|
+
case 2: return [2 /*return*/];
|
|
12241
|
+
}
|
|
12242
|
+
});
|
|
12243
|
+
}); }).toArrayAsync()];
|
|
12244
|
+
case 2:
|
|
12245
|
+
_a.sent();
|
|
12246
|
+
return [2 /*return*/, processes];
|
|
12247
|
+
}
|
|
12248
|
+
});
|
|
12249
|
+
});
|
|
12250
|
+
}
|
|
12251
|
+
Net.killByPort = killByPort;
|
|
12252
|
+
})(Net = exports.Net || (exports.Net = {}));
|
|
12244
12253
|
;
|
|
12245
12254
|
|
|
12246
12255
|
function __isObj(x) {
|
|
@@ -12268,28 +12277,28 @@ var _src_util_restartSelf;
|
|
|
12268
12277
|
var exports = _src_util_restartSelf != null ? _src_util_restartSelf : {};
|
|
12269
12278
|
var module = { exports: exports };
|
|
12270
12279
|
|
|
12271
|
-
"use strict";
|
|
12272
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12273
|
-
exports.restartSelf = void 0;
|
|
12274
|
-
var Shell_1 = _src_Shell;
|
|
12275
|
-
function restartSelf() {
|
|
12276
|
-
var command = process
|
|
12277
|
-
.argv
|
|
12278
|
-
.map(function (x) { return x.includes(' ') ? "\"".concat(x, "\"") : x; })
|
|
12279
|
-
.join(' ');
|
|
12280
|
-
var shell = new Shell_1.Shell({
|
|
12281
|
-
command: command,
|
|
12282
|
-
detached: true,
|
|
12283
|
-
});
|
|
12284
|
-
shell.onStart(function () {
|
|
12285
|
-
console.log('Exit self.');
|
|
12286
|
-
process.exit();
|
|
12287
|
-
});
|
|
12288
|
-
console.log('Cloning this process.');
|
|
12289
|
-
shell.run();
|
|
12290
|
-
}
|
|
12291
|
-
exports.restartSelf = restartSelf;
|
|
12292
|
-
;
|
|
12280
|
+
"use strict";
|
|
12281
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12282
|
+
exports.restartSelf = void 0;
|
|
12283
|
+
var Shell_1 = _src_Shell;
|
|
12284
|
+
function restartSelf() {
|
|
12285
|
+
var command = process
|
|
12286
|
+
.argv
|
|
12287
|
+
.map(function (x) { return x.includes(' ') ? "\"".concat(x, "\"") : x; })
|
|
12288
|
+
.join(' ');
|
|
12289
|
+
var shell = new Shell_1.Shell({
|
|
12290
|
+
command: command,
|
|
12291
|
+
detached: true,
|
|
12292
|
+
});
|
|
12293
|
+
shell.onStart(function () {
|
|
12294
|
+
console.log('Exit self.');
|
|
12295
|
+
process.exit();
|
|
12296
|
+
});
|
|
12297
|
+
console.log('Cloning this process.');
|
|
12298
|
+
shell.run();
|
|
12299
|
+
}
|
|
12300
|
+
exports.restartSelf = restartSelf;
|
|
12301
|
+
;
|
|
12293
12302
|
;
|
|
12294
12303
|
|
|
12295
12304
|
function __isObj(x) {
|
|
@@ -12308,24 +12317,24 @@ exports.restartSelf = restartSelf;
|
|
|
12308
12317
|
|
|
12309
12318
|
// end:source ./ModuleSimplified.js
|
|
12310
12319
|
|
|
12311
|
-
"use strict";
|
|
12312
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12313
|
-
exports.ShellUtils = exports.run = exports.Shell = exports.restartSelf = void 0;
|
|
12314
|
-
var Net_1 = _src_ps_Net;
|
|
12315
|
-
var PsList_1 = _src_ps_PsList;
|
|
12316
|
-
var Shell_1 = _src_Shell;
|
|
12317
|
-
Object.defineProperty(exports, "Shell", { enumerable: true, get: function () { return Shell_1.Shell; } });
|
|
12318
|
-
var restartSelf_1 = _src_util_restartSelf;
|
|
12319
|
-
Object.defineProperty(exports, "restartSelf", { enumerable: true, get: function () { return restartSelf_1.restartSelf; } });
|
|
12320
|
-
exports.run = Shell_1.Shell.run;
|
|
12321
|
-
exports.ShellUtils = {
|
|
12322
|
-
process: {
|
|
12323
|
-
getAll: PsList_1.PsList.getAll,
|
|
12324
|
-
getByPort: Net_1.Net.findByPort,
|
|
12325
|
-
kill: PsList_1.PsList.kill,
|
|
12326
|
-
killByPort: Net_1.Net.killByPort,
|
|
12327
|
-
}
|
|
12328
|
-
};
|
|
12320
|
+
"use strict";
|
|
12321
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12322
|
+
exports.ShellUtils = exports.run = exports.Shell = exports.restartSelf = void 0;
|
|
12323
|
+
var Net_1 = _src_ps_Net;
|
|
12324
|
+
var PsList_1 = _src_ps_PsList;
|
|
12325
|
+
var Shell_1 = _src_Shell;
|
|
12326
|
+
Object.defineProperty(exports, "Shell", { enumerable: true, get: function () { return Shell_1.Shell; } });
|
|
12327
|
+
var restartSelf_1 = _src_util_restartSelf;
|
|
12328
|
+
Object.defineProperty(exports, "restartSelf", { enumerable: true, get: function () { return restartSelf_1.restartSelf; } });
|
|
12329
|
+
exports.run = Shell_1.Shell.run;
|
|
12330
|
+
exports.ShellUtils = {
|
|
12331
|
+
process: {
|
|
12332
|
+
getAll: PsList_1.PsList.getAll,
|
|
12333
|
+
getByPort: Net_1.Net.findByPort,
|
|
12334
|
+
kill: PsList_1.PsList.kill,
|
|
12335
|
+
killByPort: Net_1.Net.killByPort,
|
|
12336
|
+
}
|
|
12337
|
+
};
|
|
12329
12338
|
|
|
12330
12339
|
|
|
12331
12340
|
}());
|