@lvce-editor/test-with-playwright 5.0.0 → 6.0.0

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/dist/main.js ADDED
@@ -0,0 +1,1399 @@
1
+ import { join } from 'node:path';
2
+
3
+ const HandleResult = 'HandleResult';
4
+ const HandleFinalResult = 'HandleFinalResult';
5
+
6
+ const getFinalResultMessage = (passed, skipped, failed, duration) => {
7
+ if (passed === 0 && skipped === 0 && failed === 0) {
8
+ return `no tests found`;
9
+ }
10
+ if (passed === 0 && skipped === 0 && failed === 1) {
11
+ return `${failed} test failed in ${duration}ms`;
12
+ }
13
+ if (passed === 0 && skipped === 1 && failed === 0) {
14
+ return `${skipped} test skipped in ${duration}ms`;
15
+ }
16
+ if (passed === 0 && skipped === 1 && failed === 1) {
17
+ return `${skipped} test skipped, ${failed} test failed in ${duration}ms`;
18
+ }
19
+ if (passed === 1 && skipped === 0 && failed === 0) {
20
+ return `${passed} test passed in ${duration}ms`;
21
+ }
22
+ if (passed === 1 && skipped === 0 && failed === 1) {
23
+ return `${passed} test passed, ${failed} test failed in ${duration}ms`;
24
+ }
25
+ if (passed === 1 && skipped === 1 && failed === 0) {
26
+ return `${passed} test passed, ${skipped} test skipped in ${duration}ms`;
27
+ }
28
+ if (passed === 1 && skipped === 1 && failed === 1) {
29
+ return `${passed} test passed, ${skipped} test skipped, ${failed} test failed in ${duration}ms`;
30
+ }
31
+ if (passed > 1 && skipped === 0 && failed === 0) {
32
+ return `${passed} tests passed in ${duration}ms`;
33
+ }
34
+ return `${passed} tests passed, ${skipped} tests skipped, ${failed} tests failed in ${duration}ms`;
35
+ };
36
+
37
+ const handleFinalResult = finalResult => {
38
+ const {
39
+ passed,
40
+ failed,
41
+ skipped,
42
+ start,
43
+ end
44
+ } = finalResult;
45
+ const duration = end - start;
46
+ const message = getFinalResultMessage(passed, skipped, failed, duration);
47
+ console.info(message);
48
+ if (failed > 0) {
49
+ process.exitCode = 1;
50
+ }
51
+ };
52
+
53
+ const Pass = 1;
54
+ const Skip = 2;
55
+ const Fail = 3;
56
+
57
+ const getDuration = (start, end) => {
58
+ return end - start;
59
+ };
60
+ const handleResultPassed = result => {
61
+ const {
62
+ name,
63
+ start,
64
+ end
65
+ } = result;
66
+ const duration = getDuration(start, end);
67
+ console.info(`test passed ${name} in ${duration}ms`);
68
+ };
69
+ const handleResultSkipped = result => {
70
+ const {
71
+ name
72
+ } = result;
73
+ console.info(`test skipped ${name}`);
74
+ };
75
+ const handleResultFailed = result => {
76
+ const {
77
+ name,
78
+ error
79
+ } = result;
80
+ console.error(`Test Failed ${name}: ${error}`);
81
+ };
82
+ const handleResult = result => {
83
+ const {
84
+ status
85
+ } = result;
86
+ switch (status) {
87
+ // @ts-ignore
88
+ case Pass:
89
+ handleResultPassed(result);
90
+ break;
91
+ // @ts-ignore
92
+ case Skip:
93
+ handleResultSkipped(result);
94
+ break;
95
+ // @ts-ignore
96
+ case Fail:
97
+ handleResultFailed(result);
98
+ break;
99
+ default:
100
+ throw new Error(`unexpected test state: ${status}`);
101
+ }
102
+ };
103
+
104
+ const commandMap = {
105
+ [HandleResult]: handleResult,
106
+ [HandleFinalResult]: handleFinalResult
107
+ };
108
+
109
+ function getDefaultExportFromCjs (x) {
110
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
111
+ }
112
+
113
+ var minimist;
114
+ var hasRequiredMinimist;
115
+
116
+ function requireMinimist () {
117
+ if (hasRequiredMinimist) return minimist;
118
+ hasRequiredMinimist = 1;
119
+
120
+ function hasKey(obj, keys) {
121
+ var o = obj;
122
+ keys.slice(0, -1).forEach(function (key) {
123
+ o = o[key] || {};
124
+ });
125
+ var key = keys[keys.length - 1];
126
+ return key in o;
127
+ }
128
+ function isNumber(x) {
129
+ if (typeof x === 'number') {
130
+ return true;
131
+ }
132
+ if (/^0x[0-9a-f]+$/i.test(x)) {
133
+ return true;
134
+ }
135
+ return /^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(x);
136
+ }
137
+ function isConstructorOrProto(obj, key) {
138
+ return key === 'constructor' && typeof obj[key] === 'function' || key === '__proto__';
139
+ }
140
+ minimist = function (args, opts) {
141
+ if (!opts) {
142
+ opts = {};
143
+ }
144
+ var flags = {
145
+ bools: {},
146
+ strings: {},
147
+ unknownFn: null
148
+ };
149
+ if (typeof opts.unknown === 'function') {
150
+ flags.unknownFn = opts.unknown;
151
+ }
152
+ if (typeof opts.boolean === 'boolean' && opts.boolean) {
153
+ flags.allBools = true;
154
+ } else {
155
+ [].concat(opts.boolean).filter(Boolean).forEach(function (key) {
156
+ flags.bools[key] = true;
157
+ });
158
+ }
159
+ var aliases = {};
160
+ function aliasIsBoolean(key) {
161
+ return aliases[key].some(function (x) {
162
+ return flags.bools[x];
163
+ });
164
+ }
165
+ Object.keys(opts.alias || {}).forEach(function (key) {
166
+ aliases[key] = [].concat(opts.alias[key]);
167
+ aliases[key].forEach(function (x) {
168
+ aliases[x] = [key].concat(aliases[key].filter(function (y) {
169
+ return x !== y;
170
+ }));
171
+ });
172
+ });
173
+ [].concat(opts.string).filter(Boolean).forEach(function (key) {
174
+ flags.strings[key] = true;
175
+ if (aliases[key]) {
176
+ [].concat(aliases[key]).forEach(function (k) {
177
+ flags.strings[k] = true;
178
+ });
179
+ }
180
+ });
181
+ var defaults = opts.default || {};
182
+ var argv = {
183
+ _: []
184
+ };
185
+ function argDefined(key, arg) {
186
+ return flags.allBools && /^--[^=]+$/.test(arg) || flags.strings[key] || flags.bools[key] || aliases[key];
187
+ }
188
+ function setKey(obj, keys, value) {
189
+ var o = obj;
190
+ for (var i = 0; i < keys.length - 1; i++) {
191
+ var key = keys[i];
192
+ if (isConstructorOrProto(o, key)) {
193
+ return;
194
+ }
195
+ if (o[key] === undefined) {
196
+ o[key] = {};
197
+ }
198
+ if (o[key] === Object.prototype || o[key] === Number.prototype || o[key] === String.prototype) {
199
+ o[key] = {};
200
+ }
201
+ if (o[key] === Array.prototype) {
202
+ o[key] = [];
203
+ }
204
+ o = o[key];
205
+ }
206
+ var lastKey = keys[keys.length - 1];
207
+ if (isConstructorOrProto(o, lastKey)) {
208
+ return;
209
+ }
210
+ if (o === Object.prototype || o === Number.prototype || o === String.prototype) {
211
+ o = {};
212
+ }
213
+ if (o === Array.prototype) {
214
+ o = [];
215
+ }
216
+ if (o[lastKey] === undefined || flags.bools[lastKey] || typeof o[lastKey] === 'boolean') {
217
+ o[lastKey] = value;
218
+ } else if (Array.isArray(o[lastKey])) {
219
+ o[lastKey].push(value);
220
+ } else {
221
+ o[lastKey] = [o[lastKey], value];
222
+ }
223
+ }
224
+ function setArg(key, val, arg) {
225
+ if (arg && flags.unknownFn && !argDefined(key, arg)) {
226
+ if (flags.unknownFn(arg) === false) {
227
+ return;
228
+ }
229
+ }
230
+ var value = !flags.strings[key] && isNumber(val) ? Number(val) : val;
231
+ setKey(argv, key.split('.'), value);
232
+ (aliases[key] || []).forEach(function (x) {
233
+ setKey(argv, x.split('.'), value);
234
+ });
235
+ }
236
+ Object.keys(flags.bools).forEach(function (key) {
237
+ setArg(key, defaults[key] === undefined ? false : defaults[key]);
238
+ });
239
+ var notFlags = [];
240
+ if (args.indexOf('--') !== -1) {
241
+ notFlags = args.slice(args.indexOf('--') + 1);
242
+ args = args.slice(0, args.indexOf('--'));
243
+ }
244
+ for (var i = 0; i < args.length; i++) {
245
+ var arg = args[i];
246
+ var key;
247
+ var next;
248
+ if (/^--.+=/.test(arg)) {
249
+ // Using [\s\S] instead of . because js doesn't support the
250
+ // 'dotall' regex modifier. See:
251
+ // http://stackoverflow.com/a/1068308/13216
252
+ var m = arg.match(/^--([^=]+)=([\s\S]*)$/);
253
+ key = m[1];
254
+ var value = m[2];
255
+ if (flags.bools[key]) {
256
+ value = value !== 'false';
257
+ }
258
+ setArg(key, value, arg);
259
+ } else if (/^--no-.+/.test(arg)) {
260
+ key = arg.match(/^--no-(.+)/)[1];
261
+ setArg(key, false, arg);
262
+ } else if (/^--.+/.test(arg)) {
263
+ key = arg.match(/^--(.+)/)[1];
264
+ next = args[i + 1];
265
+ if (next !== undefined && !/^(-|--)[^-]/.test(next) && !flags.bools[key] && !flags.allBools && (aliases[key] ? !aliasIsBoolean(key) : true)) {
266
+ setArg(key, next, arg);
267
+ i += 1;
268
+ } else if (/^(true|false)$/.test(next)) {
269
+ setArg(key, next === 'true', arg);
270
+ i += 1;
271
+ } else {
272
+ setArg(key, flags.strings[key] ? '' : true, arg);
273
+ }
274
+ } else if (/^-[^-]+/.test(arg)) {
275
+ var letters = arg.slice(1, -1).split('');
276
+ var broken = false;
277
+ for (var j = 0; j < letters.length; j++) {
278
+ next = arg.slice(j + 2);
279
+ if (next === '-') {
280
+ setArg(letters[j], next, arg);
281
+ continue;
282
+ }
283
+ if (/[A-Za-z]/.test(letters[j]) && next[0] === '=') {
284
+ setArg(letters[j], next.slice(1), arg);
285
+ broken = true;
286
+ break;
287
+ }
288
+ if (/[A-Za-z]/.test(letters[j]) && /-?\d+(\.\d*)?(e-?\d+)?$/.test(next)) {
289
+ setArg(letters[j], next, arg);
290
+ broken = true;
291
+ break;
292
+ }
293
+ if (letters[j + 1] && letters[j + 1].match(/\W/)) {
294
+ setArg(letters[j], arg.slice(j + 2), arg);
295
+ broken = true;
296
+ break;
297
+ } else {
298
+ setArg(letters[j], flags.strings[letters[j]] ? '' : true, arg);
299
+ }
300
+ }
301
+ key = arg.slice(-1)[0];
302
+ if (!broken && key !== '-') {
303
+ if (args[i + 1] && !/^(-|--)[^-]/.test(args[i + 1]) && !flags.bools[key] && (aliases[key] ? !aliasIsBoolean(key) : true)) {
304
+ setArg(key, args[i + 1], arg);
305
+ i += 1;
306
+ } else if (args[i + 1] && /^(true|false)$/.test(args[i + 1])) {
307
+ setArg(key, args[i + 1] === 'true', arg);
308
+ i += 1;
309
+ } else {
310
+ setArg(key, flags.strings[key] ? '' : true, arg);
311
+ }
312
+ }
313
+ } else {
314
+ if (!flags.unknownFn || flags.unknownFn(arg) !== false) {
315
+ argv._.push(flags.strings._ || !isNumber(arg) ? arg : Number(arg));
316
+ }
317
+ if (opts.stopEarly) {
318
+ argv._.push.apply(argv._, args.slice(i + 1));
319
+ break;
320
+ }
321
+ }
322
+ }
323
+ Object.keys(defaults).forEach(function (k) {
324
+ if (!hasKey(argv, k.split('.'))) {
325
+ setKey(argv, k.split('.'), defaults[k]);
326
+ (aliases[k] || []).forEach(function (x) {
327
+ setKey(argv, x.split('.'), defaults[k]);
328
+ });
329
+ }
330
+ });
331
+ if (opts['--']) {
332
+ argv['--'] = notFlags.slice();
333
+ } else {
334
+ notFlags.forEach(function (k) {
335
+ argv._.push(k);
336
+ });
337
+ }
338
+ return argv;
339
+ };
340
+ return minimist;
341
+ }
342
+
343
+ var minimistExports = requireMinimist();
344
+ const parseArgv = /*@__PURE__*/getDefaultExportFromCjs(minimistExports);
345
+
346
+ const parseCliArgs = argv => {
347
+ const parsed = parseArgv(argv);
348
+ const result = Object.create(null);
349
+ if (parsed.headless) {
350
+ result.headless = true;
351
+ }
352
+ if (parsed['only-extension']) {
353
+ result.onlyExtension = parsed['only-extension'];
354
+ }
355
+ if (parsed['test-path']) {
356
+ result.testPath = parsed['test-path'];
357
+ }
358
+ return result;
359
+ };
360
+
361
+ const parseEnv = env => {
362
+ const options = Object.create(null);
363
+ if (env['ONLY_EXTENSION']) {
364
+ options['onlyExtension'] = env['ONLY_EXTENSION'];
365
+ }
366
+ if (env['TEST_PATH']) {
367
+ options['testPath'] = env['TEST_PATH'];
368
+ }
369
+ return options;
370
+ };
371
+
372
+ const defaultOptions = {
373
+ testPath: '',
374
+ extensionPath: '',
375
+ headless: false
376
+ };
377
+ const getOptions = ({
378
+ argv,
379
+ env
380
+ }) => {
381
+ const parsedEnv = parseEnv(env);
382
+ const parsedArgs = parseCliArgs(argv);
383
+ return {
384
+ ...defaultOptions,
385
+ ...parsedEnv,
386
+ ...parsedArgs
387
+ };
388
+ };
389
+
390
+ const __dirname = import.meta.dirname;
391
+ const root = join(__dirname, '..', '..', '..', '..', '..');
392
+
393
+ const getTestWorkerPath = () => {
394
+ const url = import.meta.resolve('@lvce-editor/test-with-playwright-worker')
395
+ const path = fileURLToPath(url)
396
+ return path
397
+ };
398
+
399
+ const normalizeLine = line => {
400
+ if (line.startsWith('Error: ')) {
401
+ return line.slice('Error: '.length);
402
+ }
403
+ if (line.startsWith('VError: ')) {
404
+ return line.slice('VError: '.length);
405
+ }
406
+ return line;
407
+ };
408
+ const getCombinedMessage = (error, message) => {
409
+ const stringifiedError = normalizeLine(`${error}`);
410
+ if (message) {
411
+ return `${message}: ${stringifiedError}`;
412
+ }
413
+ return stringifiedError;
414
+ };
415
+ const NewLine$2 = '\n';
416
+ const getNewLineIndex$1 = (string, startIndex = undefined) => {
417
+ return string.indexOf(NewLine$2, startIndex);
418
+ };
419
+ const mergeStacks = (parent, child) => {
420
+ if (!child) {
421
+ return parent;
422
+ }
423
+ const parentNewLineIndex = getNewLineIndex$1(parent);
424
+ const childNewLineIndex = getNewLineIndex$1(child);
425
+ if (childNewLineIndex === -1) {
426
+ return parent;
427
+ }
428
+ const parentFirstLine = parent.slice(0, parentNewLineIndex);
429
+ const childRest = child.slice(childNewLineIndex);
430
+ const childFirstLine = normalizeLine(child.slice(0, childNewLineIndex));
431
+ if (parentFirstLine.includes(childFirstLine)) {
432
+ return parentFirstLine + childRest;
433
+ }
434
+ return child;
435
+ };
436
+ class VError extends Error {
437
+ constructor(error, message) {
438
+ const combinedMessage = getCombinedMessage(error, message);
439
+ super(combinedMessage);
440
+ this.name = 'VError';
441
+ if (error instanceof Error) {
442
+ this.stack = mergeStacks(this.stack, error.stack);
443
+ }
444
+ if (error.codeFrame) {
445
+ // @ts-ignore
446
+ this.codeFrame = error.codeFrame;
447
+ }
448
+ if (error.code) {
449
+ // @ts-ignore
450
+ this.code = error.code;
451
+ }
452
+ }
453
+ }
454
+
455
+ class AssertionError extends Error {
456
+ constructor(message) {
457
+ super(message);
458
+ this.name = 'AssertionError';
459
+ }
460
+ }
461
+ const Object$1 = 1;
462
+ const Number$1 = 2;
463
+ const Array$1 = 3;
464
+ const String$1 = 4;
465
+ const Boolean$1 = 5;
466
+ const Function = 6;
467
+ const Null = 7;
468
+ const Unknown = 8;
469
+ const getType = value => {
470
+ switch (typeof value) {
471
+ case 'number':
472
+ return Number$1;
473
+ case 'function':
474
+ return Function;
475
+ case 'string':
476
+ return String$1;
477
+ case 'object':
478
+ if (value === null) {
479
+ return Null;
480
+ }
481
+ if (Array.isArray(value)) {
482
+ return Array$1;
483
+ }
484
+ return Object$1;
485
+ case 'boolean':
486
+ return Boolean$1;
487
+ default:
488
+ return Unknown;
489
+ }
490
+ };
491
+ const string = value => {
492
+ const type = getType(value);
493
+ if (type !== String$1) {
494
+ throw new AssertionError('expected value to be of type string');
495
+ }
496
+ };
497
+
498
+ const isMessagePort = value => {
499
+ return value && value instanceof MessagePort;
500
+ };
501
+ const isMessagePortMain = value => {
502
+ return value && value.constructor && value.constructor.name === 'MessagePortMain';
503
+ };
504
+ const isOffscreenCanvas = value => {
505
+ return typeof OffscreenCanvas !== 'undefined' && value instanceof OffscreenCanvas;
506
+ };
507
+ const isInstanceOf = (value, constructorName) => {
508
+ return value?.constructor?.name === constructorName;
509
+ };
510
+ const isSocket = value => {
511
+ return isInstanceOf(value, 'Socket');
512
+ };
513
+ const transferrables = [isMessagePort, isMessagePortMain, isOffscreenCanvas, isSocket];
514
+ const isTransferrable = value => {
515
+ for (const fn of transferrables) {
516
+ if (fn(value)) {
517
+ return true;
518
+ }
519
+ }
520
+ return false;
521
+ };
522
+ const walkValue = (value, transferrables, isTransferrable) => {
523
+ if (!value) {
524
+ return;
525
+ }
526
+ if (isTransferrable(value)) {
527
+ transferrables.push(value);
528
+ return;
529
+ }
530
+ if (Array.isArray(value)) {
531
+ for (const item of value) {
532
+ walkValue(item, transferrables, isTransferrable);
533
+ }
534
+ return;
535
+ }
536
+ if (typeof value === 'object') {
537
+ for (const property of Object.values(value)) {
538
+ walkValue(property, transferrables, isTransferrable);
539
+ }
540
+ return;
541
+ }
542
+ };
543
+ const getTransferrables = value => {
544
+ const transferrables = [];
545
+ walkValue(value, transferrables, isTransferrable);
546
+ return transferrables;
547
+ };
548
+ const attachEvents = that => {
549
+ const handleMessage = (...args) => {
550
+ const data = that.getData(...args);
551
+ that.dispatchEvent(new MessageEvent('message', {
552
+ data
553
+ }));
554
+ };
555
+ that.onMessage(handleMessage);
556
+ const handleClose = event => {
557
+ that.dispatchEvent(new Event('close'));
558
+ };
559
+ that.onClose(handleClose);
560
+ };
561
+ class Ipc extends EventTarget {
562
+ constructor(rawIpc) {
563
+ super();
564
+ this._rawIpc = rawIpc;
565
+ attachEvents(this);
566
+ }
567
+ }
568
+ const E_INCOMPATIBLE_NATIVE_MODULE = 'E_INCOMPATIBLE_NATIVE_MODULE';
569
+ const E_MODULES_NOT_SUPPORTED_IN_ELECTRON = 'E_MODULES_NOT_SUPPORTED_IN_ELECTRON';
570
+ const ERR_MODULE_NOT_FOUND = 'ERR_MODULE_NOT_FOUND';
571
+ const NewLine$1 = '\n';
572
+ const joinLines$1 = lines => {
573
+ return lines.join(NewLine$1);
574
+ };
575
+ const RE_AT = /^\s+at/;
576
+ const RE_AT_PROMISE_INDEX = /^\s*at async Promise.all \(index \d+\)$/;
577
+ const isNormalStackLine = line => {
578
+ return RE_AT.test(line) && !RE_AT_PROMISE_INDEX.test(line);
579
+ };
580
+ const getDetails = lines => {
581
+ const index = lines.findIndex(isNormalStackLine);
582
+ if (index === -1) {
583
+ return {
584
+ actualMessage: joinLines$1(lines),
585
+ rest: []
586
+ };
587
+ }
588
+ let lastIndex = index - 1;
589
+ while (++lastIndex < lines.length) {
590
+ if (!isNormalStackLine(lines[lastIndex])) {
591
+ break;
592
+ }
593
+ }
594
+ return {
595
+ actualMessage: lines[index - 1],
596
+ rest: lines.slice(index, lastIndex)
597
+ };
598
+ };
599
+ const splitLines$1 = lines => {
600
+ return lines.split(NewLine$1);
601
+ };
602
+ const RE_MESSAGE_CODE_BLOCK_START = /^Error: The module '.*'$/;
603
+ const RE_MESSAGE_CODE_BLOCK_END = /^\s* at/;
604
+ const isMessageCodeBlockStartIndex = line => {
605
+ return RE_MESSAGE_CODE_BLOCK_START.test(line);
606
+ };
607
+ const isMessageCodeBlockEndIndex = line => {
608
+ return RE_MESSAGE_CODE_BLOCK_END.test(line);
609
+ };
610
+ const getMessageCodeBlock = stderr => {
611
+ const lines = splitLines$1(stderr);
612
+ const startIndex = lines.findIndex(isMessageCodeBlockStartIndex);
613
+ const endIndex = startIndex + lines.slice(startIndex).findIndex(isMessageCodeBlockEndIndex, startIndex);
614
+ const relevantLines = lines.slice(startIndex, endIndex);
615
+ const relevantMessage = relevantLines.join(' ').slice('Error: '.length);
616
+ return relevantMessage;
617
+ };
618
+ const isModuleNotFoundMessage = line => {
619
+ return line.includes('[ERR_MODULE_NOT_FOUND]');
620
+ };
621
+ const getModuleNotFoundError = stderr => {
622
+ const lines = splitLines$1(stderr);
623
+ const messageIndex = lines.findIndex(isModuleNotFoundMessage);
624
+ const message = lines[messageIndex];
625
+ return {
626
+ message,
627
+ code: ERR_MODULE_NOT_FOUND
628
+ };
629
+ };
630
+ const isModuleNotFoundError = stderr => {
631
+ if (!stderr) {
632
+ return false;
633
+ }
634
+ return stderr.includes('ERR_MODULE_NOT_FOUND');
635
+ };
636
+ const isModulesSyntaxError = stderr => {
637
+ if (!stderr) {
638
+ return false;
639
+ }
640
+ return stderr.includes('SyntaxError: Cannot use import statement outside a module');
641
+ };
642
+ const RE_NATIVE_MODULE_ERROR = /^innerError Error: Cannot find module '.*.node'/;
643
+ const RE_NATIVE_MODULE_ERROR_2 = /was compiled against a different Node.js version/;
644
+ const isUnhelpfulNativeModuleError = stderr => {
645
+ return RE_NATIVE_MODULE_ERROR.test(stderr) && RE_NATIVE_MODULE_ERROR_2.test(stderr);
646
+ };
647
+ const getNativeModuleErrorMessage = stderr => {
648
+ const message = getMessageCodeBlock(stderr);
649
+ return {
650
+ message: `Incompatible native node module: ${message}`,
651
+ code: E_INCOMPATIBLE_NATIVE_MODULE
652
+ };
653
+ };
654
+ const getModuleSyntaxError = () => {
655
+ return {
656
+ message: `ES Modules are not supported in electron`,
657
+ code: E_MODULES_NOT_SUPPORTED_IN_ELECTRON
658
+ };
659
+ };
660
+ const getHelpfulChildProcessError = (stdout, stderr) => {
661
+ if (isUnhelpfulNativeModuleError(stderr)) {
662
+ return getNativeModuleErrorMessage(stderr);
663
+ }
664
+ if (isModulesSyntaxError(stderr)) {
665
+ return getModuleSyntaxError();
666
+ }
667
+ if (isModuleNotFoundError(stderr)) {
668
+ return getModuleNotFoundError(stderr);
669
+ }
670
+ const lines = splitLines$1(stderr);
671
+ const {
672
+ actualMessage,
673
+ rest
674
+ } = getDetails(lines);
675
+ return {
676
+ message: actualMessage,
677
+ code: '',
678
+ stack: rest
679
+ };
680
+ };
681
+ class IpcError extends VError {
682
+ // @ts-ignore
683
+ constructor(betterMessage, stdout = '', stderr = '') {
684
+ if (stdout || stderr) {
685
+ // @ts-ignore
686
+ const {
687
+ message,
688
+ code,
689
+ stack
690
+ } = getHelpfulChildProcessError(stdout, stderr);
691
+ const cause = new Error(message);
692
+ // @ts-ignore
693
+ cause.code = code;
694
+ cause.stack = stack;
695
+ super(cause, betterMessage);
696
+ } else {
697
+ super(betterMessage);
698
+ }
699
+ // @ts-ignore
700
+ this.name = 'IpcError';
701
+ // @ts-ignore
702
+ this.stdout = stdout;
703
+ // @ts-ignore
704
+ this.stderr = stderr;
705
+ }
706
+ }
707
+ const readyMessage = 'ready';
708
+ const addListener = (emitter, type, callback) => {
709
+ if ('addEventListener' in emitter) {
710
+ emitter.addEventListener(type, callback);
711
+ } else {
712
+ emitter.on(type, callback);
713
+ }
714
+ };
715
+ const removeListener = (emitter, type, callback) => {
716
+ if ('removeEventListener' in emitter) {
717
+ emitter.removeEventListener(type, callback);
718
+ } else {
719
+ emitter.off(type, callback);
720
+ }
721
+ };
722
+ const getFirstEvent = (eventEmitter, eventMap) => {
723
+ const {
724
+ resolve,
725
+ promise
726
+ } = Promise.withResolvers();
727
+ const listenerMap = Object.create(null);
728
+ const cleanup = value => {
729
+ for (const event of Object.keys(eventMap)) {
730
+ removeListener(eventEmitter, event, listenerMap[event]);
731
+ }
732
+ resolve(value);
733
+ };
734
+ for (const [event, type] of Object.entries(eventMap)) {
735
+ const listener = event => {
736
+ cleanup({
737
+ type,
738
+ event
739
+ });
740
+ };
741
+ addListener(eventEmitter, event, listener);
742
+ listenerMap[event] = listener;
743
+ }
744
+ return promise;
745
+ };
746
+ const Exit = 1;
747
+ const Error$2 = 2;
748
+ const Message$1 = 3;
749
+ const fixNodeWorkerParameters = value => {
750
+ const transfer = getTransferrables(value);
751
+ if (transfer.length === 0) {
752
+ throw new IpcError('no transferrables found');
753
+ }
754
+ return {
755
+ newValue: value,
756
+ transfer: transfer
757
+ };
758
+ };
759
+ const getFirstNodeWorkerEvent = worker => {
760
+ return getFirstEvent(worker, {
761
+ message: Message$1,
762
+ exit: Exit,
763
+ error: Error$2
764
+ });
765
+ };
766
+ const create$1$1 = async ({
767
+ path,
768
+ argv = [],
769
+ env = process.env,
770
+ execArgv = [],
771
+ stdio,
772
+ name
773
+ }) => {
774
+ string(path);
775
+ const actualArgv = ['--ipc-type=node-worker', ...argv];
776
+ const actualEnv = {
777
+ ...env,
778
+ ELECTRON_RUN_AS_NODE: '1'
779
+ };
780
+ const ignoreStdio = stdio === 'inherit' ? undefined : true;
781
+ const {
782
+ Worker
783
+ } = await import('node:worker_threads');
784
+ const worker = new Worker(path, {
785
+ argv: actualArgv,
786
+ env: actualEnv,
787
+ execArgv,
788
+ stdout: ignoreStdio,
789
+ stderr: ignoreStdio,
790
+ name
791
+ });
792
+ const {
793
+ type,
794
+ event
795
+ } = await getFirstNodeWorkerEvent(worker);
796
+ if (type === Exit) {
797
+ throw new IpcError(`Worker exited before ipc connection was established`);
798
+ }
799
+ if (type === Error$2) {
800
+ throw new IpcError(`Worker threw an error before ipc connection was established: ${event}`);
801
+ }
802
+ if (event !== readyMessage) {
803
+ throw new IpcError('unexpected first message from worker');
804
+ }
805
+ return worker;
806
+ };
807
+ class IpcParentWithNodeWorker extends Ipc {
808
+ getData(message) {
809
+ return message;
810
+ }
811
+ send(message) {
812
+ this._rawIpc.postMessage(message);
813
+ }
814
+ sendAndTransfer(message) {
815
+ const {
816
+ newValue,
817
+ transfer
818
+ } = fixNodeWorkerParameters(message);
819
+ this._rawIpc.postMessage(newValue, transfer);
820
+ }
821
+ async dispose() {
822
+ await this._rawIpc.terminate();
823
+ }
824
+ onClose(callback) {
825
+ this._rawIpc.on('exit', callback);
826
+ }
827
+ onMessage(callback) {
828
+ this._rawIpc.on('message', callback);
829
+ }
830
+ }
831
+ const wrap$1 = worker => {
832
+ return new IpcParentWithNodeWorker(worker);
833
+ };
834
+ const IpcParentWithNodeWorker$1 = {
835
+ __proto__: null,
836
+ create: create$1$1,
837
+ wrap: wrap$1
838
+ };
839
+
840
+ const Two = '2.0';
841
+ const create$4 = (method, params) => {
842
+ return {
843
+ jsonrpc: Two,
844
+ method,
845
+ params
846
+ };
847
+ };
848
+ const callbacks = Object.create(null);
849
+ const set = (id, fn) => {
850
+ callbacks[id] = fn;
851
+ };
852
+ const get = id => {
853
+ return callbacks[id];
854
+ };
855
+ const remove = id => {
856
+ delete callbacks[id];
857
+ };
858
+ let id = 0;
859
+ const create$3 = () => {
860
+ return ++id;
861
+ };
862
+ const registerPromise = () => {
863
+ const id = create$3();
864
+ const {
865
+ resolve,
866
+ promise
867
+ } = Promise.withResolvers();
868
+ set(id, resolve);
869
+ return {
870
+ id,
871
+ promise
872
+ };
873
+ };
874
+ const create$2 = (method, params) => {
875
+ const {
876
+ id,
877
+ promise
878
+ } = registerPromise();
879
+ const message = {
880
+ jsonrpc: Two,
881
+ method,
882
+ params,
883
+ id
884
+ };
885
+ return {
886
+ message,
887
+ promise
888
+ };
889
+ };
890
+ class JsonRpcError extends Error {
891
+ constructor(message) {
892
+ super(message);
893
+ this.name = 'JsonRpcError';
894
+ }
895
+ }
896
+ const NewLine = '\n';
897
+ const DomException = 'DOMException';
898
+ const ReferenceError$1 = 'ReferenceError';
899
+ const SyntaxError$1 = 'SyntaxError';
900
+ const TypeError$1 = 'TypeError';
901
+ const getErrorConstructor = (message, type) => {
902
+ if (type) {
903
+ switch (type) {
904
+ case DomException:
905
+ return DOMException;
906
+ case TypeError$1:
907
+ return TypeError;
908
+ case SyntaxError$1:
909
+ return SyntaxError;
910
+ case ReferenceError$1:
911
+ return ReferenceError;
912
+ default:
913
+ return Error;
914
+ }
915
+ }
916
+ if (message.startsWith('TypeError: ')) {
917
+ return TypeError;
918
+ }
919
+ if (message.startsWith('SyntaxError: ')) {
920
+ return SyntaxError;
921
+ }
922
+ if (message.startsWith('ReferenceError: ')) {
923
+ return ReferenceError;
924
+ }
925
+ return Error;
926
+ };
927
+ const constructError = (message, type, name) => {
928
+ const ErrorConstructor = getErrorConstructor(message, type);
929
+ if (ErrorConstructor === DOMException && name) {
930
+ return new ErrorConstructor(message, name);
931
+ }
932
+ if (ErrorConstructor === Error) {
933
+ const error = new Error(message);
934
+ if (name && name !== 'VError') {
935
+ error.name = name;
936
+ }
937
+ return error;
938
+ }
939
+ return new ErrorConstructor(message);
940
+ };
941
+ const joinLines = lines => {
942
+ return lines.join(NewLine);
943
+ };
944
+ const splitLines = lines => {
945
+ return lines.split(NewLine);
946
+ };
947
+ const getCurrentStack = () => {
948
+ const stackLinesToSkip = 3;
949
+ const currentStack = joinLines(splitLines(new Error().stack || '').slice(stackLinesToSkip));
950
+ return currentStack;
951
+ };
952
+ const getNewLineIndex = (string, startIndex = undefined) => {
953
+ return string.indexOf(NewLine, startIndex);
954
+ };
955
+ const getParentStack = error => {
956
+ let parentStack = error.stack || error.data || error.message || '';
957
+ if (parentStack.startsWith(' at')) {
958
+ parentStack = error.message + NewLine + parentStack;
959
+ }
960
+ return parentStack;
961
+ };
962
+ const MethodNotFound = -32601;
963
+ const Custom = -32001;
964
+ const restoreJsonRpcError = error => {
965
+ const currentStack = getCurrentStack();
966
+ if (error && error instanceof Error) {
967
+ if (typeof error.stack === 'string') {
968
+ error.stack = error.stack + NewLine + currentStack;
969
+ }
970
+ return error;
971
+ }
972
+ if (error && error.code && error.code === MethodNotFound) {
973
+ const restoredError = new JsonRpcError(error.message);
974
+ const parentStack = getParentStack(error);
975
+ restoredError.stack = parentStack + NewLine + currentStack;
976
+ return restoredError;
977
+ }
978
+ if (error && error.message) {
979
+ const restoredError = constructError(error.message, error.type, error.name);
980
+ if (error.data) {
981
+ if (error.data.stack && error.data.type && error.message) {
982
+ restoredError.stack = error.data.type + ': ' + error.message + NewLine + error.data.stack + NewLine + currentStack;
983
+ } else if (error.data.stack) {
984
+ restoredError.stack = error.data.stack;
985
+ }
986
+ if (error.data.codeFrame) {
987
+ // @ts-ignore
988
+ restoredError.codeFrame = error.data.codeFrame;
989
+ }
990
+ if (error.data.code) {
991
+ // @ts-ignore
992
+ restoredError.code = error.data.code;
993
+ }
994
+ if (error.data.type) {
995
+ // @ts-ignore
996
+ restoredError.name = error.data.type;
997
+ }
998
+ } else {
999
+ if (error.stack) {
1000
+ const lowerStack = restoredError.stack || '';
1001
+ // @ts-ignore
1002
+ const indexNewLine = getNewLineIndex(lowerStack);
1003
+ const parentStack = getParentStack(error);
1004
+ // @ts-ignore
1005
+ restoredError.stack = parentStack + lowerStack.slice(indexNewLine);
1006
+ }
1007
+ if (error.codeFrame) {
1008
+ // @ts-ignore
1009
+ restoredError.codeFrame = error.codeFrame;
1010
+ }
1011
+ }
1012
+ return restoredError;
1013
+ }
1014
+ if (typeof error === 'string') {
1015
+ return new Error(`JsonRpc Error: ${error}`);
1016
+ }
1017
+ return new Error(`JsonRpc Error: ${error}`);
1018
+ };
1019
+ const unwrapJsonRpcResult = responseMessage => {
1020
+ if ('error' in responseMessage) {
1021
+ const restoredError = restoreJsonRpcError(responseMessage.error);
1022
+ throw restoredError;
1023
+ }
1024
+ if ('result' in responseMessage) {
1025
+ return responseMessage.result;
1026
+ }
1027
+ throw new JsonRpcError('unexpected response message');
1028
+ };
1029
+ const warn = (...args) => {
1030
+ console.warn(...args);
1031
+ };
1032
+ const resolve = (id, response) => {
1033
+ const fn = get(id);
1034
+ if (!fn) {
1035
+ console.log(response);
1036
+ warn(`callback ${id} may already be disposed`);
1037
+ return;
1038
+ }
1039
+ fn(response);
1040
+ remove(id);
1041
+ };
1042
+ const E_COMMAND_NOT_FOUND = 'E_COMMAND_NOT_FOUND';
1043
+ const getErrorType = prettyError => {
1044
+ if (prettyError && prettyError.type) {
1045
+ return prettyError.type;
1046
+ }
1047
+ if (prettyError && prettyError.constructor && prettyError.constructor.name) {
1048
+ return prettyError.constructor.name;
1049
+ }
1050
+ return undefined;
1051
+ };
1052
+ const isAlreadyStack = line => {
1053
+ return line.trim().startsWith('at ');
1054
+ };
1055
+ const getStack = prettyError => {
1056
+ const stackString = prettyError.stack || '';
1057
+ const newLineIndex = stackString.indexOf('\n');
1058
+ if (newLineIndex !== -1 && !isAlreadyStack(stackString.slice(0, newLineIndex))) {
1059
+ return stackString.slice(newLineIndex + 1);
1060
+ }
1061
+ return stackString;
1062
+ };
1063
+ const getErrorProperty = (error, prettyError) => {
1064
+ if (error && error.code === E_COMMAND_NOT_FOUND) {
1065
+ return {
1066
+ code: MethodNotFound,
1067
+ message: error.message,
1068
+ data: error.stack
1069
+ };
1070
+ }
1071
+ return {
1072
+ code: Custom,
1073
+ message: prettyError.message,
1074
+ data: {
1075
+ stack: getStack(prettyError),
1076
+ codeFrame: prettyError.codeFrame,
1077
+ type: getErrorType(prettyError),
1078
+ code: prettyError.code,
1079
+ name: prettyError.name
1080
+ }
1081
+ };
1082
+ };
1083
+ const create$1 = (id, error) => {
1084
+ return {
1085
+ jsonrpc: Two,
1086
+ id,
1087
+ error
1088
+ };
1089
+ };
1090
+ const getErrorResponse = (id, error, preparePrettyError, logError) => {
1091
+ const prettyError = preparePrettyError(error);
1092
+ logError(error, prettyError);
1093
+ const errorProperty = getErrorProperty(error, prettyError);
1094
+ return create$1(id, errorProperty);
1095
+ };
1096
+ const create = (message, result) => {
1097
+ return {
1098
+ jsonrpc: Two,
1099
+ id: message.id,
1100
+ result: result ?? null
1101
+ };
1102
+ };
1103
+ const getSuccessResponse = (message, result) => {
1104
+ const resultProperty = result ?? null;
1105
+ return create(message, resultProperty);
1106
+ };
1107
+ const getErrorResponseSimple = (id, error) => {
1108
+ return {
1109
+ jsonrpc: Two,
1110
+ id,
1111
+ error: {
1112
+ code: Custom,
1113
+ // @ts-ignore
1114
+ message: error.message,
1115
+ data: error
1116
+ }
1117
+ };
1118
+ };
1119
+ const getResponse = async (message, ipc, execute, preparePrettyError, logError, requiresSocket) => {
1120
+ try {
1121
+ const result = requiresSocket(message.method) ? await execute(message.method, ipc, ...message.params) : await execute(message.method, ...message.params);
1122
+ return getSuccessResponse(message, result);
1123
+ } catch (error) {
1124
+ if (ipc.canUseSimpleErrorResponse) {
1125
+ return getErrorResponseSimple(message.id, error);
1126
+ }
1127
+ return getErrorResponse(message.id, error, preparePrettyError, logError);
1128
+ }
1129
+ };
1130
+ const defaultPreparePrettyError = error => {
1131
+ return error;
1132
+ };
1133
+ const defaultLogError = () => {
1134
+ // ignore
1135
+ };
1136
+ const defaultRequiresSocket = () => {
1137
+ return false;
1138
+ };
1139
+ const defaultResolve = resolve;
1140
+
1141
+ // TODO maybe remove this in v6 or v7, only accept options object to simplify the code
1142
+ const normalizeParams = args => {
1143
+ if (args.length === 1) {
1144
+ const options = args[0];
1145
+ return {
1146
+ ipc: options.ipc,
1147
+ message: options.message,
1148
+ execute: options.execute,
1149
+ resolve: options.resolve || defaultResolve,
1150
+ preparePrettyError: options.preparePrettyError || defaultPreparePrettyError,
1151
+ logError: options.logError || defaultLogError,
1152
+ requiresSocket: options.requiresSocket || defaultRequiresSocket
1153
+ };
1154
+ }
1155
+ return {
1156
+ ipc: args[0],
1157
+ message: args[1],
1158
+ execute: args[2],
1159
+ resolve: args[3],
1160
+ preparePrettyError: args[4],
1161
+ logError: args[5],
1162
+ requiresSocket: args[6]
1163
+ };
1164
+ };
1165
+ const handleJsonRpcMessage = async (...args) => {
1166
+ const options = normalizeParams(args);
1167
+ const {
1168
+ message,
1169
+ ipc,
1170
+ execute,
1171
+ resolve,
1172
+ preparePrettyError,
1173
+ logError,
1174
+ requiresSocket
1175
+ } = options;
1176
+ if ('id' in message) {
1177
+ if ('method' in message) {
1178
+ const response = await getResponse(message, ipc, execute, preparePrettyError, logError, requiresSocket);
1179
+ try {
1180
+ ipc.send(response);
1181
+ } catch (error) {
1182
+ const errorResponse = getErrorResponse(message.id, error, preparePrettyError, logError);
1183
+ ipc.send(errorResponse);
1184
+ }
1185
+ return;
1186
+ }
1187
+ resolve(message.id, message);
1188
+ return;
1189
+ }
1190
+ if ('method' in message) {
1191
+ await getResponse(message, ipc, execute, preparePrettyError, logError, requiresSocket);
1192
+ return;
1193
+ }
1194
+ throw new JsonRpcError('unexpected message');
1195
+ };
1196
+ const invokeHelper = async (ipc, method, params, useSendAndTransfer) => {
1197
+ const {
1198
+ message,
1199
+ promise
1200
+ } = create$2(method, params);
1201
+ if (useSendAndTransfer && ipc.sendAndTransfer) {
1202
+ ipc.sendAndTransfer(message);
1203
+ } else {
1204
+ ipc.send(message);
1205
+ }
1206
+ const responseMessage = await promise;
1207
+ return unwrapJsonRpcResult(responseMessage);
1208
+ };
1209
+ const send = (transport, method, ...params) => {
1210
+ const message = create$4(method, params);
1211
+ transport.send(message);
1212
+ };
1213
+ const invoke = (ipc, method, ...params) => {
1214
+ return invokeHelper(ipc, method, params, false);
1215
+ };
1216
+ const invokeAndTransfer = (ipc, method, ...params) => {
1217
+ return invokeHelper(ipc, method, params, true);
1218
+ };
1219
+
1220
+ class CommandNotFoundError extends Error {
1221
+ constructor(command) {
1222
+ super(`Command not found ${command}`);
1223
+ this.name = 'CommandNotFoundError';
1224
+ }
1225
+ }
1226
+ const commands = Object.create(null);
1227
+ const register = commandMap => {
1228
+ Object.assign(commands, commandMap);
1229
+ };
1230
+ const getCommand = key => {
1231
+ return commands[key];
1232
+ };
1233
+ const execute = (command, ...args) => {
1234
+ const fn = getCommand(command);
1235
+ if (!fn) {
1236
+ throw new CommandNotFoundError(command);
1237
+ }
1238
+ return fn(...args);
1239
+ };
1240
+
1241
+ const createRpc = ipc => {
1242
+ const rpc = {
1243
+ // @ts-ignore
1244
+ ipc,
1245
+ /**
1246
+ * @deprecated
1247
+ */
1248
+ send(method, ...params) {
1249
+ send(ipc, method, ...params);
1250
+ },
1251
+ invoke(method, ...params) {
1252
+ return invoke(ipc, method, ...params);
1253
+ },
1254
+ invokeAndTransfer(method, ...params) {
1255
+ return invokeAndTransfer(ipc, method, ...params);
1256
+ },
1257
+ async dispose() {
1258
+ await ipc?.dispose();
1259
+ }
1260
+ };
1261
+ return rpc;
1262
+ };
1263
+ const requiresSocket = () => {
1264
+ return false;
1265
+ };
1266
+ const preparePrettyError = error => {
1267
+ return error;
1268
+ };
1269
+ const logError = () => {
1270
+ // handled by renderer worker
1271
+ };
1272
+ const handleMessage = event => {
1273
+ const actualRequiresSocket = event?.target?.requiresSocket || requiresSocket;
1274
+ const actualExecute = event?.target?.execute || execute;
1275
+ return handleJsonRpcMessage(event.target, event.data, actualExecute, resolve, preparePrettyError, logError, actualRequiresSocket);
1276
+ };
1277
+ const handleIpc = ipc => {
1278
+ if ('addEventListener' in ipc) {
1279
+ ipc.addEventListener('message', handleMessage);
1280
+ } else if ('on' in ipc) {
1281
+ // deprecated
1282
+ ipc.on('message', handleMessage);
1283
+ }
1284
+ };
1285
+ const create$6 = async ({
1286
+ commandMap,
1287
+ argv,
1288
+ execArgv,
1289
+ path,
1290
+ stdio,
1291
+ env
1292
+ }) => {
1293
+ // TODO create a commandMap per rpc instance
1294
+ register(commandMap);
1295
+ const rawIpc = await IpcParentWithNodeWorker$1.create({
1296
+ argv,
1297
+ execArgv,
1298
+ path,
1299
+ stdio,
1300
+ env
1301
+ });
1302
+ const ipc = IpcParentWithNodeWorker$1.wrap(rawIpc);
1303
+ handleIpc(ipc);
1304
+ const rpc = createRpc(ipc);
1305
+ // @ts-ignore
1306
+ rpc.stdout = ipc._rawIpc.stdout;
1307
+ // @ts-ignore
1308
+ rpc.stderr = ipc._rawIpc.stderr;
1309
+ // @ts-ignore
1310
+ return rpc;
1311
+ };
1312
+ const NodeWorkerRpcParent = {
1313
+ __proto__: null,
1314
+ create: create$6
1315
+ };
1316
+
1317
+ const RunAllTests = 'RunAllTests';
1318
+
1319
+ const runAllTests = async ({
1320
+ onlyExtension,
1321
+ testPath,
1322
+ cwd,
1323
+ headless,
1324
+ timeout,
1325
+ commandMap,
1326
+ testWorkerPath
1327
+ }) => {
1328
+ // TODO use `using` once supported
1329
+ const rpc = await NodeWorkerRpcParent.create({
1330
+ path: testWorkerPath,
1331
+ argv: [],
1332
+ commandMap,
1333
+ stdio: 'inherit'
1334
+ });
1335
+ await rpc.invoke(RunAllTests, onlyExtension, testPath, cwd, headless, timeout);
1336
+ await rpc.dispose();
1337
+ };
1338
+
1339
+ const handleCliArgs = async ({
1340
+ argv,
1341
+ env,
1342
+ commandMap,
1343
+ cwd
1344
+ }) => {
1345
+ const options = getOptions({
1346
+ argv,
1347
+ env
1348
+ });
1349
+ const {
1350
+ onlyExtension
1351
+ } = options;
1352
+ const {
1353
+ testPath
1354
+ } = options;
1355
+ const {
1356
+ headless
1357
+ } = options;
1358
+ const timeout = 30_000;
1359
+ const testWorkerPath = getTestWorkerPath();
1360
+
1361
+ // TODO
1362
+ // console.log({ argv, env })
1363
+ await runAllTests({
1364
+ // @ts-ignore
1365
+ onlyExtension,
1366
+ testPath,
1367
+ cwd,
1368
+ headless,
1369
+ timeout,
1370
+ commandMap,
1371
+ testWorkerPath
1372
+ });
1373
+ };
1374
+
1375
+ const {
1376
+ argv
1377
+ } = process;
1378
+ const {
1379
+ env
1380
+ } = process;
1381
+ const on = (event, listener) => {
1382
+ process.on(event, listener);
1383
+ };
1384
+
1385
+ const handleUncaughtExceptionMonitor = error => {
1386
+ console.log(`[test] uncaught exception ${error}`);
1387
+ };
1388
+
1389
+ const main = async () => {
1390
+ on('uncaughtExceptionMonitor', handleUncaughtExceptionMonitor);
1391
+ await handleCliArgs({
1392
+ argv: argv,
1393
+ env: env,
1394
+ commandMap: commandMap,
1395
+ cwd: process.cwd()
1396
+ });
1397
+ };
1398
+
1399
+ main();