app-bundler 0.2.22 → 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/lib/cli.js CHANGED
@@ -2158,282 +2158,282 @@ var _node_modules_tslib_tslib;
2158
2158
  var exports = _node_modules_tslib_tslib != null ? _node_modules_tslib_tslib : {};
2159
2159
  var module = { exports: exports };
2160
2160
 
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
- });
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
+ });
2437
2437
  ;
2438
2438
 
2439
2439
  function __isObj(x) {
@@ -10358,18 +10358,18 @@ var _src_util_path;
10358
10358
  var exports = _src_util_path != null ? _src_util_path : {};
10359
10359
  var module = { exports: exports };
10360
10360
 
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;
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;
10373
10373
  ;
10374
10374
 
10375
10375
  function __isObj(x) {
@@ -10397,64 +10397,64 @@ var _src_util_ShellWrapperUtil;
10397
10397
  var exports = _src_util_ShellWrapperUtil != null ? _src_util_ShellWrapperUtil : {};
10398
10398
  var module = { exports: exports };
10399
10399
 
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 = {}));
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 = {}));
10458
10458
  ;
10459
10459
 
10460
10460
  function __isObj(x) {
@@ -10482,84 +10482,84 @@ var _src_util_command;
10482
10482
  var exports = _src_util_command != null ? _src_util_command : {};
10483
10483
  var module = { exports: exports };
10484
10484
 
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
- }
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
+ }
10563
10563
  ;
10564
10564
 
10565
10565
  function __isObj(x) {
@@ -10587,60 +10587,60 @@ var _src_ValueExtractor;
10587
10587
  var exports = _src_ValueExtractor != null ? _src_ValueExtractor : {};
10588
10588
  var module = { exports: exports };
10589
10589
 
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;
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;
10644
10644
  ;
10645
10645
 
10646
10646
  function __isObj(x) {
@@ -10668,17 +10668,17 @@ var _src_util_serialize;
10668
10668
  var exports = _src_util_serialize != null ? _src_util_serialize : {};
10669
10669
  var module = { exports: exports };
10670
10670
 
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;
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;
10682
10682
  ;
10683
10683
 
10684
10684
  function __isObj(x) {
@@ -10706,135 +10706,135 @@ var _src_CommunicationChannel;
10706
10706
  var exports = _src_CommunicationChannel != null ? _src_CommunicationChannel : {};
10707
10707
  var module = { exports: exports };
10708
10708
 
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;
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;
10838
10838
  ;
10839
10839
 
10840
10840
  function __isObj(x) {
@@ -10862,30 +10862,30 @@ var _src_util_events;
10862
10862
  var exports = _src_util_events != null ? _src_util_events : {};
10863
10863
  var module = { exports: exports };
10864
10864
 
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
- }
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
+ }
10889
10889
  ;
10890
10890
 
10891
10891
  function __isObj(x) {
@@ -10913,33 +10913,33 @@ var _src_util_ShellParamsUtil;
10913
10913
  var exports = _src_util_ShellParamsUtil != null ? _src_util_ShellParamsUtil : {};
10914
10914
  var module = { exports: exports };
10915
10915
 
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
- };
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
+ };
10943
10943
  ;
10944
10944
 
10945
10945
  function __isObj(x) {
@@ -10967,46 +10967,46 @@ var _src_util_ShellErrorExitsHandler;
10967
10967
  var exports = _src_util_ShellErrorExitsHandler != null ? _src_util_ShellErrorExitsHandler : {};
10968
10968
  var module = { exports: exports };
10969
10969
 
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;
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;
11010
11010
  ;
11011
11011
 
11012
11012
  function __isObj(x) {
@@ -11034,119 +11034,119 @@ var _src_util_ShellStalledOutputHandler;
11034
11034
  var exports = _src_util_ShellStalledOutputHandler != null ? _src_util_ShellStalledOutputHandler : {};
11035
11035
  var module = { exports: exports };
11036
11036
 
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;
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;
11150
11150
  ;
11151
11151
 
11152
11152
  function __isObj(x) {
@@ -11174,563 +11174,563 @@ var _src_Shell;
11174
11174
  var exports = _src_Shell != null ? _src_Shell : {};
11175
11175
  var module = { exports: exports };
11176
11176
 
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 = {}));
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 = {}));
11734
11734
  ;
11735
11735
 
11736
11736
  function __isObj(x) {
@@ -11758,292 +11758,292 @@ var _src_ps_PsList;
11758
11758
  var exports = _src_ps_PsList != null ? _src_ps_PsList : {};
11759
11759
  var module = { exports: exports };
11760
11760
 
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 = {}));
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 = {}));
12047
12047
  ;
12048
12048
 
12049
12049
  function __isObj(x) {
@@ -12071,185 +12071,185 @@ var _src_ps_Net;
12071
12071
  var exports = _src_ps_Net != null ? _src_ps_Net : {};
12072
12072
  var module = { exports: exports };
12073
12073
 
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 = {}));
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 = {}));
12253
12253
  ;
12254
12254
 
12255
12255
  function __isObj(x) {
@@ -12277,28 +12277,28 @@ var _src_util_restartSelf;
12277
12277
  var exports = _src_util_restartSelf != null ? _src_util_restartSelf : {};
12278
12278
  var module = { exports: exports };
12279
12279
 
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
- ;
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
+ ;
12302
12302
  ;
12303
12303
 
12304
12304
  function __isObj(x) {
@@ -12317,24 +12317,24 @@ exports.restartSelf = restartSelf;
12317
12317
 
12318
12318
  // end:source ./ModuleSimplified.js
12319
12319
 
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
- };
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
+ };
12338
12338
 
12339
12339
 
12340
12340
  }());