app-bundler 0.2.21 → 0.2.23

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