weboptimizer 2.0.1263 → 2.0.1264

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/index.js CHANGED
@@ -40,7 +40,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
40
40
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
41
41
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
42
42
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
43
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
43
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
44
44
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
45
45
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
46
46
  // endregion
@@ -63,563 +63,588 @@ var main = function main(context) {
63
63
  var commandLineArguments = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : process.argv;
64
64
  var webOptimizerPath = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : __dirname;
65
65
  var environment = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : eval('process.env');
66
- return (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
67
- var configuration, clear;
68
- return _regenerator["default"].wrap(function _callee3$(_context3) {
69
- while (1) {
70
- switch (_context3.prev = _context3.next) {
71
- case 0:
72
- configuration = (0, _configurator.load)(context, currentWorkingDirectory, commandLineArguments, webOptimizerPath, environment);
73
- clear = _clientnode["default"].noop();
74
- _context3.prev = 2;
75
- return _context3.delegateYield( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
76
- var processOptions, childProcessOptions, childProcesses, processPromises, possibleArguments, closeEventHandlers, dynamicConfiguration, count, filePath, additionalArguments, _iterator, _step, file, _iterator2, _step2, _filePath, _iterator3, _step3, filePathPattern, buildConfigurations, tidiedUp, tidyUp, testModuleFilePaths, _iterator9, _step9, buildConfiguration, expression, _iterator10, _step10, _filePath6, handleTask, finished, closeHandler, _iterator14, _step14, closeEventName;
77
- return _regenerator["default"].wrap(function _callee2$(_context2) {
78
- while (1) {
79
- switch (_context2.prev = _context2.next) {
80
- case 0:
81
- // region controller
82
- processOptions = {
83
- cwd: configuration.path.context,
84
- env: environment
85
- };
86
- childProcessOptions = _objectSpread({
87
- shell: true,
88
- stdio: 'inherit'
89
- }, processOptions);
90
- childProcesses = [];
91
- processPromises = [];
92
- possibleArguments = ['build', 'build:types', 'clear', 'document', 'lint', 'preinstall', 'serve', 'test', 'test:browser', 'test:coverage', 'test:coverage:report', 'check:types'];
93
- closeEventHandlers = [];
94
- if (!(configuration.givenCommandLineArguments.length > 2)) {
95
- _context2.next = 74;
96
- break;
97
- }
98
- // region temporary save dynamically given configurations
99
- // NOTE: We need a copy of given arguments array.
100
- dynamicConfiguration = {
101
- givenCommandLineArguments: configuration.givenCommandLineArguments.slice()
102
- };
103
- if (configuration.givenCommandLineArguments.length > 3 && _clientnode["default"].stringParseEncodedObject(configuration.givenCommandLineArguments[configuration.givenCommandLineArguments.length - 1], configuration, 'configuration')) configuration.givenCommandLineArguments.pop();
104
- count = 0;
105
- filePath = (0, _path.resolve)(configuration.path.context, ".dynamicConfiguration-".concat(count, ".json"));
106
- case 11:
107
- if (!true) {
108
- _context2.next = 20;
109
- break;
110
- }
111
- filePath = (0, _path.resolve)(configuration.path.context, ".dynamicConfiguration-".concat(count, ".json"));
112
- _context2.next = 15;
113
- return _clientnode["default"].isFile(filePath);
114
- case 15:
115
- if (_context2.sent) {
116
- _context2.next = 17;
117
- break;
118
- }
119
- return _context2.abrupt("break", 20);
120
- case 17:
121
- count += 1;
122
- _context2.next = 11;
66
+ return (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
67
+ var configuration, clear, processOptions, childProcessOptions, childProcesses, processPromises, possibleArguments, closeEventHandlers, dynamicConfiguration, count, filePath, additionalArguments, _iterator, _step, file, _iterator2, _step2, _filePath, _iterator3, _step3, filePathPattern, buildConfigurations, tidiedUp, tidyUp, testModuleFilePaths, _iterator9, _step9, buildConfiguration, expression, _iterator10, _step10, _loop, handleTask, finished, closeHandler, _iterator13, _step13, closeEventName;
68
+ return _regenerator["default"].wrap(function _callee2$(_context3) {
69
+ while (1) switch (_context3.prev = _context3.next) {
70
+ case 0:
71
+ configuration = (0, _configurator.load)(context, currentWorkingDirectory, commandLineArguments, webOptimizerPath, environment);
72
+ clear = _clientnode["default"].noop();
73
+ _context3.prev = 2;
74
+ // region controller
75
+ processOptions = {
76
+ cwd: configuration.path.context,
77
+ env: environment
78
+ };
79
+ childProcessOptions = _objectSpread({
80
+ shell: true,
81
+ stdio: 'inherit'
82
+ }, processOptions);
83
+ childProcesses = [];
84
+ processPromises = [];
85
+ possibleArguments = ['build', 'build:types', 'clear', 'document', 'lint', 'preinstall', 'serve', 'test', 'test:browser', 'test:coverage', 'test:coverage:report', 'check:types'];
86
+ closeEventHandlers = [];
87
+ if (!(configuration.givenCommandLineArguments.length > 2)) {
88
+ _context3.next = 118;
89
+ break;
90
+ }
91
+ // region temporary save dynamically given configurations
92
+ // NOTE: We need a copy of given arguments array.
93
+ dynamicConfiguration = {
94
+ givenCommandLineArguments: configuration.givenCommandLineArguments.slice()
95
+ };
96
+ if (configuration.givenCommandLineArguments.length > 3 && _clientnode["default"].stringParseEncodedObject(configuration.givenCommandLineArguments[configuration.givenCommandLineArguments.length - 1], configuration, 'configuration')) configuration.givenCommandLineArguments.pop();
97
+ count = 0;
98
+ filePath = (0, _path.resolve)(configuration.path.context, ".dynamicConfiguration-".concat(count, ".json"));
99
+ case 14:
100
+ if (!true) {
101
+ _context3.next = 23;
102
+ break;
103
+ }
104
+ filePath = (0, _path.resolve)(configuration.path.context, ".dynamicConfiguration-".concat(count, ".json"));
105
+ _context3.next = 18;
106
+ return _clientnode["default"].isFile(filePath);
107
+ case 18:
108
+ if (_context3.sent) {
109
+ _context3.next = 20;
110
+ break;
111
+ }
112
+ return _context3.abrupt("break", 23);
113
+ case 20:
114
+ count += 1;
115
+ _context3.next = 14;
116
+ break;
117
+ case 23:
118
+ _context3.next = 25;
119
+ return (0, _promises.writeFile)(filePath, JSON.stringify(dynamicConfiguration));
120
+ case 25:
121
+ additionalArguments = commandLineArguments.splice(3); /// region register exit handler to tidy up
122
+ clear = function clear(error) {
123
+ // NOTE: Close handler have to be synchronous.
124
+ if (_clientnode["default"].isFileSync(filePath)) (0, _fs.unlinkSync)(filePath);
125
+ if (error) throw error;
126
+ };
127
+ closeEventHandlers.push(clear);
128
+ /// endregion
129
+ // endregion
130
+ // region handle clear
131
+ /*
132
+ NOTE: Some tasks could depend on previously created artefacts
133
+ packages so a preceding clear should not be performed in that
134
+ cases.
135
+ NOTE: If we have a dependency cycle we need to preserve files
136
+ during pre-install phase.
137
+ */
138
+ if (!(!['build', 'build:types', 'preinstall', 'serve', 'test', 'test:browser', 'test:coverage', 'test:coverage:report'].includes(configuration.givenCommandLineArguments[2]) && possibleArguments.includes(configuration.givenCommandLineArguments[2]))) {
139
+ _context3.next = 67;
140
+ break;
141
+ }
142
+ if (!((0, _path.resolve)(configuration.path.target.base) === (0, _path.resolve)(configuration.path.context))) {
143
+ _context3.next = 56;
144
+ break;
145
+ }
146
+ _context3.next = 32;
147
+ return _clientnode["default"].walkDirectoryRecursively(configuration.path.target.base, /*#__PURE__*/function () {
148
+ var _ref2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(file) {
149
+ var type, _file$stats;
150
+ return _regenerator["default"].wrap(function _callee$(_context) {
151
+ while (1) switch (_context.prev = _context.next) {
152
+ case 0:
153
+ if (!_helper["default"].isFilePathInLocation(file.path, configuration.path.ignore.concat(configuration.module.directoryNames, configuration.loader.directoryNames).map(function (filePath) {
154
+ return (0, _path.resolve)(configuration.path.context, filePath);
155
+ }).filter(function (filePath) {
156
+ return !configuration.path.context.startsWith(filePath);
157
+ }))) {
158
+ _context.next = 2;
123
159
  break;
124
- case 20:
125
- _context2.next = 22;
126
- return (0, _promises.writeFile)(filePath, JSON.stringify(dynamicConfiguration));
127
- case 22:
128
- additionalArguments = commandLineArguments.splice(3); /// region register exit handler to tidy up
129
- clear = function clear(error) {
130
- // NOTE: Close handler have to be synchronous.
131
- if (_clientnode["default"].isFileSync(filePath)) (0, _fs.unlinkSync)(filePath);
132
- if (error) throw error;
133
- };
134
- closeEventHandlers.push(clear);
135
- /// endregion
136
- // endregion
137
- // region handle clear
138
- /*
139
- NOTE: Some tasks could depend on previously created artefacts
140
- packages so a preceding clear should not be performed in that
141
- cases.
142
- NOTE: If we have a dependency cycle we need to preserve files
143
- during pre-install phase.
144
- */
145
- if (!(!['build', 'build:types', 'preinstall', 'serve', 'test', 'test:browser', 'test:coverage', 'test:coverage:report'].includes(configuration.givenCommandLineArguments[2]) && possibleArguments.includes(configuration.givenCommandLineArguments[2]))) {
146
- _context2.next = 64;
147
- break;
148
- }
149
- if (!((0, _path.resolve)(configuration.path.target.base) === (0, _path.resolve)(configuration.path.context))) {
150
- _context2.next = 53;
151
- break;
152
- }
153
- _context2.next = 29;
154
- return _clientnode["default"].walkDirectoryRecursively(configuration.path.target.base, /*#__PURE__*/function () {
155
- var _ref2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(file) {
156
- var type, _file$stats;
157
- return _regenerator["default"].wrap(function _callee$(_context) {
158
- while (1) {
159
- switch (_context.prev = _context.next) {
160
- case 0:
161
- if (!_helper["default"].isFilePathInLocation(file.path, configuration.path.ignore.concat(configuration.module.directoryNames, configuration.loader.directoryNames).map(function (filePath) {
162
- return (0, _path.resolve)(configuration.path.context, filePath);
163
- }).filter(function (filePath) {
164
- return !configuration.path.context.startsWith(filePath);
165
- }))) {
166
- _context.next = 2;
167
- break;
168
- }
169
- return _context.abrupt("return", false);
170
- case 2:
171
- _context.t0 = _regenerator["default"].keys(configuration.buildContext.types);
172
- case 3:
173
- if ((_context.t1 = _context.t0()).done) {
174
- _context.next = 15;
175
- break;
176
- }
177
- type = _context.t1.value;
178
- if (!new RegExp(configuration.buildContext.types[type].filePathPattern).test(file.path)) {
179
- _context.next = 13;
180
- break;
181
- }
182
- if (!((_file$stats = file.stats) !== null && _file$stats !== void 0 && _file$stats.isDirectory())) {
183
- _context.next = 10;
184
- break;
185
- }
186
- _context.next = 9;
187
- return new Promise(function (resolve, reject) {
188
- return (0, _rimraf["default"])(file.path, {
189
- glob: false
190
- }, function (error) {
191
- return error ? reject(error) : resolve();
192
- });
193
- });
194
- case 9:
195
- return _context.abrupt("return", false);
196
- case 10:
197
- _context.next = 12;
198
- return (0, _promises.unlink)(file.path);
199
- case 12:
200
- return _context.abrupt("break", 15);
201
- case 13:
202
- _context.next = 3;
203
- break;
204
- case 15:
205
- case "end":
206
- return _context.stop();
207
- }
208
- }
209
- }, _callee);
210
- }));
211
- return function (_x) {
212
- return _ref2.apply(this, arguments);
213
- };
214
- }());
215
- case 29:
216
- _context2.t0 = _createForOfIteratorHelper;
217
- _context2.next = 32;
218
- return _clientnode["default"].walkDirectoryRecursively(configuration.path.target.base, function () {
219
- return false;
220
- }, configuration.encoding);
221
- case 32:
222
- _context2.t1 = _context2.sent;
223
- _iterator = (0, _context2.t0)(_context2.t1);
224
- _context2.prev = 34;
225
- _iterator.s();
226
- case 36:
227
- if ((_step = _iterator.n()).done) {
228
- _context2.next = 43;
229
- break;
230
- }
231
- file = _step.value;
232
- if (!file.name.startsWith('npm-debug')) {
233
- _context2.next = 41;
234
- break;
235
- }
236
- _context2.next = 41;
237
- return (0, _promises.unlink)(file.path);
238
- case 41:
239
- _context2.next = 36;
160
+ }
161
+ return _context.abrupt("return", false);
162
+ case 2:
163
+ _context.t0 = _regenerator["default"].keys(configuration.buildContext.types);
164
+ case 3:
165
+ if ((_context.t1 = _context.t0()).done) {
166
+ _context.next = 15;
240
167
  break;
241
- case 43:
242
- _context2.next = 48;
168
+ }
169
+ type = _context.t1.value;
170
+ if (!new RegExp(configuration.buildContext.types[type].filePathPattern).test(file.path)) {
171
+ _context.next = 13;
243
172
  break;
244
- case 45:
245
- _context2.prev = 45;
246
- _context2.t2 = _context2["catch"](34);
247
- _iterator.e(_context2.t2);
248
- case 48:
249
- _context2.prev = 48;
250
- _iterator.f();
251
- return _context2.finish(48);
252
- case 51:
253
- _context2.next = 55;
173
+ }
174
+ if (!((_file$stats = file.stats) !== null && _file$stats !== void 0 && _file$stats.isDirectory())) {
175
+ _context.next = 10;
254
176
  break;
255
- case 53:
256
- _context2.next = 55;
257
- return new Promise(function (resolve, reject) {
258
- return (0, _rimraf["default"])(configuration.path.target.base, {
259
- glob: false
260
- }, function (error) {
261
- return error ? reject(error) : resolve();
262
- });
263
- });
264
- case 55:
265
- _context2.next = 57;
266
- return _clientnode["default"].isDirectory(configuration.path.apiDocumentation);
267
- case 57:
268
- if (!_context2.sent) {
269
- _context2.next = 60;
270
- break;
271
- }
272
- _context2.next = 60;
273
- return new Promise(function (resolve, reject) {
274
- return (0, _rimraf["default"])(configuration.path.apiDocumentation, {
275
- glob: false
276
- }, function (error) {
277
- return error ? reject(error) : resolve();
278
- });
177
+ }
178
+ _context.next = 9;
179
+ return new Promise(function (resolve, reject) {
180
+ return (0, _rimraf["default"])(file.path, {
181
+ glob: false
182
+ }, function (error) {
183
+ return error ? reject(error) : resolve();
279
184
  });
280
- case 60:
281
- _iterator2 = _createForOfIteratorHelper(configuration.path.tidyUpOnClear);
282
- try {
283
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
284
- _filePath = _step2.value;
285
- if (_filePath) if (_clientnode["default"].isFileSync(_filePath))
286
- // NOTE: Close handler have to be synchronous.
287
- (0, _fs.unlinkSync)(_filePath);else if (_clientnode["default"].isDirectorySync(_filePath)) (0, _rimraf.sync)(_filePath, {
288
- glob: false
289
- });
290
- }
291
- } catch (err) {
292
- _iterator2.e(err);
293
- } finally {
294
- _iterator2.f();
295
- }
296
- _iterator3 = _createForOfIteratorHelper(configuration.path.tidyUpOnClearGlobs.pattern);
297
- try {
298
- for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
299
- filePathPattern = _step3.value;
300
- if (filePathPattern) (0, _rimraf.sync)(filePathPattern, configuration.path.tidyUpOnClearGlobs.options);
301
- }
302
- } catch (err) {
303
- _iterator3.e(err);
304
- } finally {
305
- _iterator3.f();
306
- }
307
- case 64:
308
- // endregion
309
- // region handle build
310
- buildConfigurations = _helper["default"].resolveBuildConfigurationFilePaths(configuration.buildContext.types, configuration.path.source.asset.base, configuration.path.ignore.concat(configuration.module.directoryNames, configuration.loader.directoryNames).map(function (filePath) {
311
- return (0, _path.resolve)(configuration.path.context, filePath);
312
- }).filter(function (filePath) {
313
- return !configuration.path.context.startsWith(filePath);
314
- }), configuration["package"].main.fileNames);
315
- if (['build', 'document', 'test', 'test:coverage', 'test:coverage:report'].includes(commandLineArguments[2])) {
316
- tidiedUp = false;
317
- tidyUp = function tidyUp() {
318
- /*
319
- Determines all none javaScript entities which have been
320
- emitted as single module to remove.
321
- */
322
- if (tidiedUp) return;
323
- tidiedUp = true;
324
- for (var _i = 0, _Object$entries = Object.entries(configuration.injection.entry.normalized); _i < _Object$entries.length; _i++) {
325
- var _Object$entries$_i = (0, _slicedToArray2["default"])(_Object$entries[_i], 2),
326
- chunkName = _Object$entries$_i[0],
327
- chunk = _Object$entries$_i[1];
328
- var _iterator4 = _createForOfIteratorHelper(chunk),
329
- _step4;
330
- try {
331
- for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
332
- var moduleID = _step4.value;
333
- var _filePath2 = _helper["default"].determineModuleFilePath(moduleID, configuration.module.aliases, configuration.module.replacements.normal, {
334
- file: configuration.extensions.file.internal
335
- }, configuration.path.context, configuration.path.source.asset.base, configuration.path.ignore, configuration.module.directoryNames, configuration["package"].main.fileNames, configuration["package"].main.propertyNames, configuration["package"].aliasPropertyNames, configuration.encoding);
336
- var type = null;
337
- if (_filePath2) type = _helper["default"].determineAssetType(_filePath2, configuration.buildContext.types, configuration.path);
338
- if (typeof type === 'string' && configuration.buildContext.types[type]) {
339
- var _filePath3 = _helper["default"].renderFilePathTemplate(_helper["default"].stripLoader(configuration.files.compose.javaScript), {
340
- '[name]': chunkName
341
- });
342
- /*
343
- NOTE: Close handler have to be
344
- synchronous.
345
- */
346
- if (configuration.buildContext.types[type].outputExtension === 'js' && _clientnode["default"].isFileSync(_filePath3)) (0, _fs.chmodSync)(_filePath3, '755');
347
- }
348
- }
349
- } catch (err) {
350
- _iterator4.e(err);
351
- } finally {
352
- _iterator4.f();
353
- }
354
- }
355
- var _iterator5 = _createForOfIteratorHelper(configuration.path.tidyUp),
356
- _step5;
357
- try {
358
- for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
359
- var _filePath4 = _step5.value;
360
- if (_filePath4) if (_clientnode["default"].isFileSync(_filePath4))
361
- // NOTE: Close handler have to be synchronous.
362
- (0, _fs.unlinkSync)(_filePath4);else if (_clientnode["default"].isDirectorySync(_filePath4)) (0, _rimraf.sync)(_filePath4, {
363
- glob: false
364
- });
365
- }
366
- } catch (err) {
367
- _iterator5.e(err);
368
- } finally {
369
- _iterator5.f();
370
- }
371
- var _iterator6 = _createForOfIteratorHelper(configuration.path.tidyUpGlobs.pattern),
372
- _step6;
373
- try {
374
- for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
375
- var _filePathPattern = _step6.value;
376
- if (_filePathPattern) (0, _rimraf.sync)(_filePathPattern, configuration.path.tidyUpOnClearGlobs.options);
377
- }
378
- } catch (err) {
379
- _iterator6.e(err);
380
- } finally {
381
- _iterator6.f();
382
- }
383
- };
384
- closeEventHandlers.push(tidyUp);
185
+ });
186
+ case 9:
187
+ return _context.abrupt("return", false);
188
+ case 10:
189
+ _context.next = 12;
190
+ return (0, _promises.unlink)(file.path);
191
+ case 12:
192
+ return _context.abrupt("break", 15);
193
+ case 13:
194
+ _context.next = 3;
195
+ break;
196
+ case 15:
197
+ case "end":
198
+ return _context.stop();
199
+ }
200
+ }, _callee);
201
+ }));
202
+ return function (_x) {
203
+ return _ref2.apply(this, arguments);
204
+ };
205
+ }());
206
+ case 32:
207
+ _context3.t0 = _createForOfIteratorHelper;
208
+ _context3.next = 35;
209
+ return _clientnode["default"].walkDirectoryRecursively(configuration.path.target.base, function () {
210
+ return false;
211
+ }, configuration.encoding);
212
+ case 35:
213
+ _context3.t1 = _context3.sent;
214
+ _iterator = (0, _context3.t0)(_context3.t1);
215
+ _context3.prev = 37;
216
+ _iterator.s();
217
+ case 39:
218
+ if ((_step = _iterator.n()).done) {
219
+ _context3.next = 46;
220
+ break;
221
+ }
222
+ file = _step.value;
223
+ if (!file.name.startsWith('npm-debug')) {
224
+ _context3.next = 44;
225
+ break;
226
+ }
227
+ _context3.next = 44;
228
+ return (0, _promises.unlink)(file.path);
229
+ case 44:
230
+ _context3.next = 39;
231
+ break;
232
+ case 46:
233
+ _context3.next = 51;
234
+ break;
235
+ case 48:
236
+ _context3.prev = 48;
237
+ _context3.t2 = _context3["catch"](37);
238
+ _iterator.e(_context3.t2);
239
+ case 51:
240
+ _context3.prev = 51;
241
+ _iterator.f();
242
+ return _context3.finish(51);
243
+ case 54:
244
+ _context3.next = 58;
245
+ break;
246
+ case 56:
247
+ _context3.next = 58;
248
+ return new Promise(function (resolve, reject) {
249
+ return (0, _rimraf["default"])(configuration.path.target.base, {
250
+ glob: false
251
+ }, function (error) {
252
+ return error ? reject(error) : resolve();
253
+ });
254
+ });
255
+ case 58:
256
+ _context3.next = 60;
257
+ return _clientnode["default"].isDirectory(configuration.path.apiDocumentation);
258
+ case 60:
259
+ if (!_context3.sent) {
260
+ _context3.next = 63;
261
+ break;
262
+ }
263
+ _context3.next = 63;
264
+ return new Promise(function (resolve, reject) {
265
+ return (0, _rimraf["default"])(configuration.path.apiDocumentation, {
266
+ glob: false
267
+ }, function (error) {
268
+ return error ? reject(error) : resolve();
269
+ });
270
+ });
271
+ case 63:
272
+ _iterator2 = _createForOfIteratorHelper(configuration.path.tidyUpOnClear);
273
+ try {
274
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
275
+ _filePath = _step2.value;
276
+ if (_filePath) if (_clientnode["default"].isFileSync(_filePath))
277
+ // NOTE: Close handler have to be synchronous.
278
+ (0, _fs.unlinkSync)(_filePath);else if (_clientnode["default"].isDirectorySync(_filePath)) (0, _rimraf.sync)(_filePath, {
279
+ glob: false
280
+ });
281
+ }
282
+ } catch (err) {
283
+ _iterator2.e(err);
284
+ } finally {
285
+ _iterator2.f();
286
+ }
287
+ _iterator3 = _createForOfIteratorHelper(configuration.path.tidyUpOnClearGlobs.pattern);
288
+ try {
289
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
290
+ filePathPattern = _step3.value;
291
+ if (filePathPattern) (0, _rimraf.sync)(filePathPattern, configuration.path.tidyUpOnClearGlobs.options);
292
+ }
293
+ } catch (err) {
294
+ _iterator3.e(err);
295
+ } finally {
296
+ _iterator3.f();
297
+ }
298
+ case 67:
299
+ // endregion
300
+ // region handle build
301
+ buildConfigurations = _helper["default"].resolveBuildConfigurationFilePaths(configuration.buildContext.types, configuration.path.source.asset.base, configuration.path.ignore.concat(configuration.module.directoryNames, configuration.loader.directoryNames).map(function (filePath) {
302
+ return (0, _path.resolve)(configuration.path.context, filePath);
303
+ }).filter(function (filePath) {
304
+ return !configuration.path.context.startsWith(filePath);
305
+ }), configuration["package"].main.fileNames);
306
+ if (!['build', 'document', 'test', 'test:coverage', 'test:coverage:report'].includes(commandLineArguments[2])) {
307
+ _context3.next = 75;
308
+ break;
309
+ }
310
+ tidiedUp = false;
311
+ tidyUp = function tidyUp() {
312
+ /*
313
+ Determines all none javaScript entities which have been
314
+ emitted as single module to remove.
315
+ */
316
+ if (tidiedUp) return;
317
+ tidiedUp = true;
318
+ for (var _i = 0, _Object$entries = Object.entries(configuration.injection.entry.normalized); _i < _Object$entries.length; _i++) {
319
+ var _Object$entries$_i = (0, _slicedToArray2["default"])(_Object$entries[_i], 2),
320
+ chunkName = _Object$entries$_i[0],
321
+ chunk = _Object$entries$_i[1];
322
+ var _iterator4 = _createForOfIteratorHelper(chunk),
323
+ _step4;
324
+ try {
325
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
326
+ var moduleID = _step4.value;
327
+ var _filePath2 = _helper["default"].determineModuleFilePath(moduleID, configuration.module.aliases, configuration.module.replacements.normal, {
328
+ file: configuration.extensions.file.internal
329
+ }, configuration.path.context, configuration.path.source.asset.base, configuration.path.ignore, configuration.module.directoryNames, configuration["package"].main.fileNames, configuration["package"].main.propertyNames, configuration["package"].aliasPropertyNames, configuration.encoding);
330
+ var type = null;
331
+ if (_filePath2) type = _helper["default"].determineAssetType(_filePath2, configuration.buildContext.types, configuration.path);
332
+ if (typeof type === 'string' && configuration.buildContext.types[type]) {
333
+ var _filePath3 = _helper["default"].renderFilePathTemplate(_helper["default"].stripLoader(configuration.files.compose.javaScript), {
334
+ '[name]': chunkName
335
+ });
336
+ /*
337
+ NOTE: Close handler have to be
338
+ synchronous.
339
+ */
340
+ if (configuration.buildContext.types[type].outputExtension === 'js' && _clientnode["default"].isFileSync(_filePath3)) (0, _fs.chmodSync)(_filePath3, '755');
341
+ }
342
+ }
343
+ } catch (err) {
344
+ _iterator4.e(err);
345
+ } finally {
346
+ _iterator4.f();
347
+ }
348
+ }
349
+ var _iterator5 = _createForOfIteratorHelper(configuration.path.tidyUp),
350
+ _step5;
351
+ try {
352
+ for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
353
+ var _filePath4 = _step5.value;
354
+ if (_filePath4) if (_clientnode["default"].isFileSync(_filePath4))
355
+ // NOTE: Close handler have to be synchronous.
356
+ (0, _fs.unlinkSync)(_filePath4);else if (_clientnode["default"].isDirectorySync(_filePath4)) (0, _rimraf.sync)(_filePath4, {
357
+ glob: false
358
+ });
359
+ }
360
+ } catch (err) {
361
+ _iterator5.e(err);
362
+ } finally {
363
+ _iterator5.f();
364
+ }
365
+ var _iterator6 = _createForOfIteratorHelper(configuration.path.tidyUpGlobs.pattern),
366
+ _step6;
367
+ try {
368
+ for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
369
+ var _filePathPattern = _step6.value;
370
+ if (_filePathPattern) (0, _rimraf.sync)(_filePathPattern, configuration.path.tidyUpOnClearGlobs.options);
371
+ }
372
+ } catch (err) {
373
+ _iterator6.e(err);
374
+ } finally {
375
+ _iterator6.f();
376
+ }
377
+ };
378
+ closeEventHandlers.push(tidyUp);
385
379
 
386
- /*
387
- Triggers complete asset compiling and bundles them into the
388
- final productive output.
389
- */
390
- processPromises.push(new Promise(function (resolve, reject) {
391
- var commandLineArguments = (configuration.commandLine.build.arguments || []).concat(additionalArguments);
392
- console.info('Running "' + ("".concat(configuration.commandLine.build.command, " ") + commandLineArguments.join(' ')).trim() + '"');
380
+ /*
381
+ Triggers complete asset compiling and bundles them into the
382
+ final productive output.
383
+ */
384
+ processPromises.push(new Promise(function (resolve, reject) {
385
+ var commandLineArguments = (configuration.commandLine.build.arguments || []).concat(additionalArguments);
386
+ console.info('Running "' + ("".concat(configuration.commandLine.build.command, " ") + commandLineArguments.join(' ')).trim() + '"');
393
387
 
394
- /*
395
- NOTE: Take current weboptimizer's dependencies into
396
- account.
397
- */
398
- childProcessOptions.env.PATH += ":".concat(webOptimizerPath, "/node_modules/.bin");
399
- var childProcess = (0, _child_process.spawn)(configuration.commandLine.build.command, commandLineArguments, childProcessOptions);
400
- var copyAdditionalFilesAndTidyUp = function copyAdditionalFilesAndTidyUp() {
401
- var _iterator7 = _createForOfIteratorHelper(configuration.files.additionalPaths),
402
- _step7;
403
- try {
404
- for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
405
- var _filePath5 = _step7.value;
406
- var sourcePath = (0, _path.join)(configuration.path.source.base, _filePath5);
407
- var targetPath = (0, _path.join)(configuration.path.target.base, _filePath5);
388
+ /*
389
+ NOTE: Take current weboptimizer's dependencies into
390
+ account.
391
+ */
392
+ childProcessOptions.env.PATH += ":".concat(webOptimizerPath, "/node_modules/.bin");
393
+ var childProcess = (0, _child_process.spawn)(configuration.commandLine.build.command, commandLineArguments, childProcessOptions);
394
+ var copyAdditionalFilesAndTidyUp = function copyAdditionalFilesAndTidyUp() {
395
+ var _iterator7 = _createForOfIteratorHelper(configuration.files.additionalPaths),
396
+ _step7;
397
+ try {
398
+ for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
399
+ var _filePath5 = _step7.value;
400
+ var sourcePath = (0, _path.join)(configuration.path.source.base, _filePath5);
401
+ var targetPath = (0, _path.join)(configuration.path.target.base, _filePath5);
408
402
 
409
- // NOTE: Close handler have to be synchronous.
410
- if (_clientnode["default"].isDirectorySync(sourcePath)) {
411
- if (_clientnode["default"].isDirectorySync(targetPath)) (0, _rimraf.sync)(targetPath, {
412
- glob: false
413
- });
414
- _clientnode["default"].copyDirectoryRecursiveSync(sourcePath, targetPath);
415
- } else if (_clientnode["default"].isFileSync(sourcePath)) _clientnode["default"].copyFileSync(sourcePath, targetPath);
416
- }
417
- } catch (err) {
418
- _iterator7.e(err);
419
- } finally {
420
- _iterator7.f();
421
- }
422
- tidyUp();
423
- };
424
- var closeHandler = _clientnode["default"].getProcessCloseHandler(resolve, reject, null, commandLineArguments[2] === 'build' ? copyAdditionalFilesAndTidyUp : tidyUp);
425
- var _iterator8 = _createForOfIteratorHelper(_clientnode.CloseEventNames),
426
- _step8;
427
- try {
428
- for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
429
- var closeEventName = _step8.value;
430
- childProcess.on(closeEventName, closeHandler);
431
- }
432
- } catch (err) {
433
- _iterator8.e(err);
434
- } finally {
435
- _iterator8.f();
436
- }
437
- childProcesses.push(childProcess);
438
- return childProcesses;
439
- }));
440
- // endregion
441
- // region handle pre-install
442
- } else if (configuration.library && configuration.givenCommandLineArguments[2] === 'preinstall') {
443
- // Perform all file specific preprocessing stuff.
444
- testModuleFilePaths = [];
445
- if (_clientnode["default"].isPlainObject(configuration['test:browser'].injection) && configuration['test:browser'].injection.entry) testModuleFilePaths = _helper["default"].determineModuleLocations(configuration['test:browser'].injection.entry, configuration.module.aliases, configuration.module.replacements.normal, {
446
- file: configuration.extensions.file.internal
447
- }, configuration.path.context, configuration.path.source.asset.base, configuration.path.ignore).filePaths;
448
- _iterator9 = _createForOfIteratorHelper(buildConfigurations);
449
- try {
450
- for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
451
- buildConfiguration = _step9.value;
452
- expression = buildConfiguration[configuration.givenCommandLineArguments[2]].trim();
453
- _iterator10 = _createForOfIteratorHelper(buildConfiguration.filePaths);
454
- try {
455
- for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
456
- _filePath6 = _step10.value;
457
- if (!testModuleFilePaths.includes(_filePath6)) {
458
- (function () {
459
- var evaluated = _clientnode["default"].stringEvaluate("`".concat(expression, "`"), {
460
- global: global,
461
- self: configuration,
462
- buildConfiguration: buildConfiguration,
463
- path: _path["default"],
464
- additionalArguments: additionalArguments,
465
- filePath: _filePath6
466
- });
467
- if (evaluated.error) throw new Error('Error occurred during processing given ' + "command: ".concat(evaluated.error));
468
- console.info("Running \"".concat(evaluated.result, "\""));
469
- processPromises.push(new Promise(function (resolve, reject) {
470
- return [_clientnode["default"].handleChildProcess((0, _child_process.exec)(evaluated.result, _objectSpread({
471
- encoding: configuration.encoding
472
- }, processOptions), function (error) {
473
- return error ? reject(error) : resolve({
474
- reason: 'Finished.',
475
- parameters: []
476
- });
477
- }))];
478
- }));
479
- })();
480
- }
481
- }
482
- } catch (err) {
483
- _iterator10.e(err);
484
- } finally {
485
- _iterator10.f();
486
- }
487
- }
488
- } catch (err) {
489
- _iterator9.e(err);
490
- } finally {
491
- _iterator9.f();
492
- }
493
- }
494
- // endregion
495
- // region handle remaining tasks
496
- handleTask = function handleTask(type) {
497
- var tasks = Array.isArray(configuration.commandLine[type]) ? configuration.commandLine[type] : [configuration.commandLine[type]];
498
- var _iterator11 = _createForOfIteratorHelper(tasks),
499
- _step11;
500
- try {
501
- var _loop = function _loop() {
502
- var task = _step11.value;
503
- var evaluated = _clientnode["default"].stringEvaluate(Object.prototype.hasOwnProperty.call(task, 'indicator') ? task.indicator : 'true', {
504
- global: global,
505
- self: configuration,
506
- path: _path["default"]
507
- });
508
- if (evaluated.error) throw new Error('Error occurred during processing given task: ' + evaluated.error);
509
- if (evaluated.result) processPromises.push(new Promise(function (resolve, reject) {
510
- var commandLineArguments = (task.arguments || []).concat(additionalArguments);
511
- console.info('Running "' + ("".concat(task.command, " ") + commandLineArguments.join(' ')).trim() + '"');
512
- var childProcess = (0, _child_process.spawn)(task.command, commandLineArguments, childProcessOptions);
513
- var closeHandler = _clientnode["default"].getProcessCloseHandler(resolve, reject);
514
- var _iterator12 = _createForOfIteratorHelper(_clientnode.CloseEventNames),
515
- _step12;
516
- try {
517
- for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {
518
- var closeEventName = _step12.value;
519
- childProcess.on(closeEventName, closeHandler);
520
- }
521
- } catch (err) {
522
- _iterator12.e(err);
523
- } finally {
524
- _iterator12.f();
525
- }
526
- childProcesses.push(childProcess);
527
- return childProcesses;
528
- }));
529
- };
530
- for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
531
- _loop();
532
- }
533
- } catch (err) {
534
- _iterator11.e(err);
535
- } finally {
536
- _iterator11.f();
537
- }
538
- }; /// region a-/synchronous
539
- if (!['document', 'test', 'test:coverage', 'test:coverage:report'].includes(configuration.givenCommandLineArguments[2])) {
540
- _context2.next = 73;
541
- break;
542
- }
543
- _context2.next = 70;
544
- return Promise.all(processPromises);
545
- case 70:
546
- handleTask(configuration.givenCommandLineArguments[2]);
547
- _context2.next = 74;
548
- break;
549
- case 73:
550
- if (['build:types', 'check:types', 'lint', 'serve', 'test:browser'].includes(configuration.givenCommandLineArguments[2])) handleTask(configuration.givenCommandLineArguments[2]);
551
- case 74:
552
- finished = false;
553
- closeHandler = function closeHandler() {
554
- if (!finished) {
555
- var _iterator13 = _createForOfIteratorHelper(closeEventHandlers),
556
- _step13;
557
- try {
558
- for (_iterator13.s(); !(_step13 = _iterator13.n()).done;) {
559
- var closeEventHandler = _step13.value;
560
- closeEventHandler.apply(void 0, arguments);
561
- }
562
- } catch (err) {
563
- _iterator13.e(err);
564
- } finally {
565
- _iterator13.f();
566
- }
567
- }
568
- finished = true;
569
- };
570
- _iterator14 = _createForOfIteratorHelper(_clientnode.CloseEventNames);
571
- try {
572
- for (_iterator14.s(); !(_step14 = _iterator14.n()).done;) {
573
- closeEventName = _step14.value;
574
- process.on(closeEventName, closeHandler);
575
- }
576
- } catch (err) {
577
- _iterator14.e(err);
578
- } finally {
579
- _iterator14.f();
580
- }
581
- if (require.main === module && (configuration.givenCommandLineArguments.length < 3 || !possibleArguments.includes(configuration.givenCommandLineArguments[2]))) console.info("Give one of \"".concat(possibleArguments.join('", "'), "\" as command ") + 'line argument. You can provide a json string as second ' + 'parameter to dynamically overwrite some configurations.\n');
582
- // endregion
583
- // region forward nested return codes
584
- _context2.prev = 79;
585
- _context2.next = 82;
586
- return Promise.all(processPromises);
587
- case 82:
588
- _context2.next = 88;
589
- break;
590
- case 84:
591
- _context2.prev = 84;
592
- _context2.t3 = _context2["catch"](79);
593
- console.error(_context2.t3);
594
- process.exit(_context2.t3.returnCode);
595
- case 88:
596
- case "end":
597
- return _context2.stop();
598
- }
403
+ // NOTE: Close handler have to be synchronous.
404
+ if (_clientnode["default"].isDirectorySync(sourcePath)) {
405
+ if (_clientnode["default"].isDirectorySync(targetPath)) (0, _rimraf.sync)(targetPath, {
406
+ glob: false
407
+ });
408
+ _clientnode["default"].copyDirectoryRecursiveSync(sourcePath, targetPath);
409
+ } else if (_clientnode["default"].isFileSync(sourcePath)) _clientnode["default"].copyFileSync(sourcePath, targetPath);
599
410
  }
600
- }, _callee2, null, [[34, 45, 48, 51], [79, 84]]);
601
- })(), "t0", 4);
602
- case 4:
603
- _context3.next = 13;
411
+ } catch (err) {
412
+ _iterator7.e(err);
413
+ } finally {
414
+ _iterator7.f();
415
+ }
416
+ tidyUp();
417
+ };
418
+ var closeHandler = _clientnode["default"].getProcessCloseHandler(resolve, reject, null, commandLineArguments[2] === 'build' ? copyAdditionalFilesAndTidyUp : tidyUp);
419
+ var _iterator8 = _createForOfIteratorHelper(_clientnode.CloseEventNames),
420
+ _step8;
421
+ try {
422
+ for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
423
+ var closeEventName = _step8.value;
424
+ childProcess.on(closeEventName, closeHandler);
425
+ }
426
+ } catch (err) {
427
+ _iterator8.e(err);
428
+ } finally {
429
+ _iterator8.f();
430
+ }
431
+ childProcesses.push(childProcess);
432
+ return childProcesses;
433
+ }));
434
+ // endregion
435
+ // region handle pre-install
436
+ _context3.next = 110;
437
+ break;
438
+ case 75:
439
+ if (!(configuration.library && configuration.givenCommandLineArguments[2] === 'preinstall')) {
440
+ _context3.next = 110;
441
+ break;
442
+ }
443
+ // Perform all file specific preprocessing stuff.
444
+ testModuleFilePaths = [];
445
+ if (_clientnode["default"].isPlainObject(configuration['test:browser'].injection) && configuration['test:browser'].injection.entry) testModuleFilePaths = _helper["default"].determineModuleLocations(configuration['test:browser'].injection.entry, configuration.module.aliases, configuration.module.replacements.normal, {
446
+ file: configuration.extensions.file.internal
447
+ }, configuration.path.context, configuration.path.source.asset.base, configuration.path.ignore).filePaths;
448
+ _iterator9 = _createForOfIteratorHelper(buildConfigurations);
449
+ _context3.prev = 79;
450
+ _iterator9.s();
451
+ case 81:
452
+ if ((_step9 = _iterator9.n()).done) {
453
+ _context3.next = 102;
454
+ break;
455
+ }
456
+ buildConfiguration = _step9.value;
457
+ expression = buildConfiguration[configuration.givenCommandLineArguments[2]].trim();
458
+ _iterator10 = _createForOfIteratorHelper(buildConfiguration.filePaths);
459
+ _context3.prev = 85;
460
+ _loop = /*#__PURE__*/_regenerator["default"].mark(function _loop() {
461
+ var filePath, evaluated;
462
+ return _regenerator["default"].wrap(function _loop$(_context2) {
463
+ while (1) switch (_context2.prev = _context2.next) {
464
+ case 0:
465
+ filePath = _step10.value;
466
+ if (testModuleFilePaths.includes(filePath)) {
467
+ _context2.next = 7;
468
+ break;
469
+ }
470
+ evaluated = _clientnode["default"].stringEvaluate("`".concat(expression, "`"), {
471
+ global: global,
472
+ self: configuration,
473
+ buildConfiguration: buildConfiguration,
474
+ path: _path["default"],
475
+ additionalArguments: additionalArguments,
476
+ filePath: filePath
477
+ });
478
+ if (!evaluated.error) {
479
+ _context2.next = 5;
480
+ break;
481
+ }
482
+ throw new Error('Error occurred during processing given ' + "command: ".concat(evaluated.error));
483
+ case 5:
484
+ console.info("Running \"".concat(evaluated.result, "\""));
485
+ processPromises.push(new Promise(function (resolve, reject) {
486
+ return [_clientnode["default"].handleChildProcess((0, _child_process.exec)(evaluated.result, _objectSpread({
487
+ encoding: configuration.encoding
488
+ }, processOptions), function (error) {
489
+ return error ? reject(error) : resolve({
490
+ reason: 'Finished.',
491
+ parameters: []
492
+ });
493
+ }))];
494
+ }));
495
+ case 7:
496
+ case "end":
497
+ return _context2.stop();
498
+ }
499
+ }, _loop);
500
+ });
501
+ _iterator10.s();
502
+ case 88:
503
+ if ((_step10 = _iterator10.n()).done) {
504
+ _context3.next = 92;
505
+ break;
506
+ }
507
+ return _context3.delegateYield(_loop(), "t3", 90);
508
+ case 90:
509
+ _context3.next = 88;
510
+ break;
511
+ case 92:
512
+ _context3.next = 97;
513
+ break;
514
+ case 94:
515
+ _context3.prev = 94;
516
+ _context3.t4 = _context3["catch"](85);
517
+ _iterator10.e(_context3.t4);
518
+ case 97:
519
+ _context3.prev = 97;
520
+ _iterator10.f();
521
+ return _context3.finish(97);
522
+ case 100:
523
+ _context3.next = 81;
524
+ break;
525
+ case 102:
526
+ _context3.next = 107;
527
+ break;
528
+ case 104:
529
+ _context3.prev = 104;
530
+ _context3.t5 = _context3["catch"](79);
531
+ _iterator9.e(_context3.t5);
532
+ case 107:
533
+ _context3.prev = 107;
534
+ _iterator9.f();
535
+ return _context3.finish(107);
536
+ case 110:
537
+ // endregion
538
+ // region handle remaining tasks
539
+ handleTask = function handleTask(type) {
540
+ var tasks = Array.isArray(configuration.commandLine[type]) ? configuration.commandLine[type] : [configuration.commandLine[type]];
541
+ var _iterator11 = _createForOfIteratorHelper(tasks),
542
+ _step11;
543
+ try {
544
+ var _loop2 = function _loop2() {
545
+ var task = _step11.value;
546
+ var evaluated = _clientnode["default"].stringEvaluate(Object.prototype.hasOwnProperty.call(task, 'indicator') ? task.indicator : 'true', {
547
+ global: global,
548
+ self: configuration,
549
+ path: _path["default"]
550
+ });
551
+ if (evaluated.error) throw new Error('Error occurred during processing given task: ' + evaluated.error);
552
+ if (evaluated.result) processPromises.push(new Promise(function (resolve, reject) {
553
+ var commandLineArguments = (task.arguments || []).concat(additionalArguments);
554
+ console.info('Running "' + ("".concat(task.command, " ") + commandLineArguments.join(' ')).trim() + '"');
555
+ var childProcess = (0, _child_process.spawn)(task.command, commandLineArguments, childProcessOptions);
556
+ var closeHandler = _clientnode["default"].getProcessCloseHandler(resolve, reject);
557
+ var _iterator12 = _createForOfIteratorHelper(_clientnode.CloseEventNames),
558
+ _step12;
559
+ try {
560
+ for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {
561
+ var closeEventName = _step12.value;
562
+ childProcess.on(closeEventName, closeHandler);
563
+ }
564
+ } catch (err) {
565
+ _iterator12.e(err);
566
+ } finally {
567
+ _iterator12.f();
568
+ }
569
+ childProcesses.push(childProcess);
570
+ return childProcesses;
571
+ }));
572
+ };
573
+ for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
574
+ _loop2();
575
+ }
576
+ } catch (err) {
577
+ _iterator11.e(err);
578
+ } finally {
579
+ _iterator11.f();
580
+ }
581
+ }; /// region a-/synchronous
582
+ if (!['document', 'test', 'test:coverage', 'test:coverage:report'].includes(configuration.givenCommandLineArguments[2])) {
583
+ _context3.next = 117;
604
584
  break;
605
- case 6:
606
- _context3.prev = 6;
607
- _context3.t1 = _context3["catch"](2);
608
- if (!configuration.debug) {
609
- _context3.next = 12;
610
- break;
585
+ }
586
+ _context3.next = 114;
587
+ return Promise.all(processPromises);
588
+ case 114:
589
+ handleTask(configuration.givenCommandLineArguments[2]);
590
+ _context3.next = 118;
591
+ break;
592
+ case 117:
593
+ if (['build:types', 'check:types', 'lint', 'serve', 'test:browser'].includes(configuration.givenCommandLineArguments[2])) handleTask(configuration.givenCommandLineArguments[2]);
594
+ case 118:
595
+ finished = false;
596
+ closeHandler = function closeHandler() {
597
+ if (!finished) for (var _i2 = 0, _closeEventHandlers = closeEventHandlers; _i2 < _closeEventHandlers.length; _i2++) {
598
+ var closeEventHandler = _closeEventHandlers[_i2];
599
+ closeEventHandler.apply(void 0, arguments);
611
600
  }
612
- throw _context3.t1;
613
- case 12:
614
- console.error(_context3.t1);
615
- case 13:
616
- return _context3.abrupt("return", clear);
617
- case 14:
618
- case "end":
619
- return _context3.stop();
620
- }
601
+ finished = true;
602
+ };
603
+ _iterator13 = _createForOfIteratorHelper(_clientnode.CloseEventNames);
604
+ try {
605
+ for (_iterator13.s(); !(_step13 = _iterator13.n()).done;) {
606
+ closeEventName = _step13.value;
607
+ process.on(closeEventName, closeHandler);
608
+ }
609
+ } catch (err) {
610
+ _iterator13.e(err);
611
+ } finally {
612
+ _iterator13.f();
613
+ }
614
+ if (require.main === module && (configuration.givenCommandLineArguments.length < 3 || !possibleArguments.includes(configuration.givenCommandLineArguments[2]))) console.info("Give one of \"".concat(possibleArguments.join('", "'), "\" as command ") + 'line argument. You can provide a json string as second ' + 'parameter to dynamically overwrite some configurations.\n');
615
+ // endregion
616
+ // region forward nested return codes
617
+ _context3.prev = 123;
618
+ _context3.next = 126;
619
+ return Promise.all(processPromises);
620
+ case 126:
621
+ _context3.next = 132;
622
+ break;
623
+ case 128:
624
+ _context3.prev = 128;
625
+ _context3.t6 = _context3["catch"](123);
626
+ console.error(_context3.t6);
627
+ process.exit(_context3.t6.returnCode);
628
+ case 132:
629
+ _context3.next = 141;
630
+ break;
631
+ case 134:
632
+ _context3.prev = 134;
633
+ _context3.t7 = _context3["catch"](2);
634
+ if (!configuration.debug) {
635
+ _context3.next = 140;
636
+ break;
637
+ }
638
+ throw _context3.t7;
639
+ case 140:
640
+ console.error(_context3.t7);
641
+ case 141:
642
+ return _context3.abrupt("return", clear);
643
+ case 142:
644
+ case "end":
645
+ return _context3.stop();
621
646
  }
622
- }, _callee3, null, [[2, 6]]);
647
+ }, _callee2, null, [[2, 134], [37, 48, 51, 54], [79, 104, 107, 110], [85, 94, 97, 100], [123, 128]]);
623
648
  }))();
624
649
  } catch (e) {
625
650
  return Promise.reject(e);