vitest 0.0.90 → 0.0.94

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.
@@ -0,0 +1,2409 @@
1
+ import path$5 from 'path';
2
+ import fs$5 from 'fs';
3
+ import require$$0 from 'util';
4
+ import require$$0$1 from 'child_process';
5
+ import { c as commonjsGlobal, a as signalExit, b as onetime$1 } from './index-5cc247ff.js';
6
+ import require$$0$2 from 'os';
7
+ import require$$0$4 from 'buffer';
8
+ import require$$0$3 from 'stream';
9
+ import 'assert';
10
+ import 'events';
11
+
12
+ var findUp$1 = {exports: {}};
13
+
14
+ var locatePath = {exports: {}};
15
+
16
+ class Node {
17
+ /// value;
18
+ /// next;
19
+
20
+ constructor(value) {
21
+ this.value = value;
22
+
23
+ // TODO: Remove this when targeting Node.js 12.
24
+ this.next = undefined;
25
+ }
26
+ }
27
+
28
+ class Queue$1 {
29
+ // TODO: Use private class fields when targeting Node.js 12.
30
+ // #_head;
31
+ // #_tail;
32
+ // #_size;
33
+
34
+ constructor() {
35
+ this.clear();
36
+ }
37
+
38
+ enqueue(value) {
39
+ const node = new Node(value);
40
+
41
+ if (this._head) {
42
+ this._tail.next = node;
43
+ this._tail = node;
44
+ } else {
45
+ this._head = node;
46
+ this._tail = node;
47
+ }
48
+
49
+ this._size++;
50
+ }
51
+
52
+ dequeue() {
53
+ const current = this._head;
54
+ if (!current) {
55
+ return;
56
+ }
57
+
58
+ this._head = this._head.next;
59
+ this._size--;
60
+ return current.value;
61
+ }
62
+
63
+ clear() {
64
+ this._head = undefined;
65
+ this._tail = undefined;
66
+ this._size = 0;
67
+ }
68
+
69
+ get size() {
70
+ return this._size;
71
+ }
72
+
73
+ * [Symbol.iterator]() {
74
+ let current = this._head;
75
+
76
+ while (current) {
77
+ yield current.value;
78
+ current = current.next;
79
+ }
80
+ }
81
+ }
82
+
83
+ var yoctoQueue = Queue$1;
84
+
85
+ const Queue = yoctoQueue;
86
+
87
+ const pLimit$1 = concurrency => {
88
+ if (!((Number.isInteger(concurrency) || concurrency === Infinity) && concurrency > 0)) {
89
+ throw new TypeError('Expected `concurrency` to be a number from 1 and up');
90
+ }
91
+
92
+ const queue = new Queue();
93
+ let activeCount = 0;
94
+
95
+ const next = () => {
96
+ activeCount--;
97
+
98
+ if (queue.size > 0) {
99
+ queue.dequeue()();
100
+ }
101
+ };
102
+
103
+ const run = async (fn, resolve, ...args) => {
104
+ activeCount++;
105
+
106
+ const result = (async () => fn(...args))();
107
+
108
+ resolve(result);
109
+
110
+ try {
111
+ await result;
112
+ } catch {}
113
+
114
+ next();
115
+ };
116
+
117
+ const enqueue = (fn, resolve, ...args) => {
118
+ queue.enqueue(run.bind(null, fn, resolve, ...args));
119
+
120
+ (async () => {
121
+ // This function needs to wait until the next microtask before comparing
122
+ // `activeCount` to `concurrency`, because `activeCount` is updated asynchronously
123
+ // when the run function is dequeued and called. The comparison in the if-statement
124
+ // needs to happen asynchronously as well to get an up-to-date value for `activeCount`.
125
+ await Promise.resolve();
126
+
127
+ if (activeCount < concurrency && queue.size > 0) {
128
+ queue.dequeue()();
129
+ }
130
+ })();
131
+ };
132
+
133
+ const generator = (fn, ...args) => new Promise(resolve => {
134
+ enqueue(fn, resolve, ...args);
135
+ });
136
+
137
+ Object.defineProperties(generator, {
138
+ activeCount: {
139
+ get: () => activeCount
140
+ },
141
+ pendingCount: {
142
+ get: () => queue.size
143
+ },
144
+ clearQueue: {
145
+ value: () => {
146
+ queue.clear();
147
+ }
148
+ }
149
+ });
150
+
151
+ return generator;
152
+ };
153
+
154
+ var pLimit_1 = pLimit$1;
155
+
156
+ const pLimit = pLimit_1;
157
+
158
+ class EndError extends Error {
159
+ constructor(value) {
160
+ super();
161
+ this.value = value;
162
+ }
163
+ }
164
+
165
+ // The input can also be a promise, so we await it
166
+ const testElement = async (element, tester) => tester(await element);
167
+
168
+ // The input can also be a promise, so we `Promise.all()` them both
169
+ const finder = async element => {
170
+ const values = await Promise.all(element);
171
+ if (values[1] === true) {
172
+ throw new EndError(values[0]);
173
+ }
174
+
175
+ return false;
176
+ };
177
+
178
+ const pLocate$1 = async (iterable, tester, options) => {
179
+ options = {
180
+ concurrency: Infinity,
181
+ preserveOrder: true,
182
+ ...options
183
+ };
184
+
185
+ const limit = pLimit(options.concurrency);
186
+
187
+ // Start all the promises concurrently with optional limit
188
+ const items = [...iterable].map(element => [element, limit(testElement, element, tester)]);
189
+
190
+ // Check the promises either serially or concurrently
191
+ const checkLimit = pLimit(options.preserveOrder ? 1 : Infinity);
192
+
193
+ try {
194
+ await Promise.all(items.map(element => checkLimit(finder, element)));
195
+ } catch (error) {
196
+ if (error instanceof EndError) {
197
+ return error.value;
198
+ }
199
+
200
+ throw error;
201
+ }
202
+ };
203
+
204
+ var pLocate_1 = pLocate$1;
205
+
206
+ const path$4 = path$5;
207
+ const fs$4 = fs$5;
208
+ const {promisify: promisify$2} = require$$0;
209
+ const pLocate = pLocate_1;
210
+
211
+ const fsStat = promisify$2(fs$4.stat);
212
+ const fsLStat = promisify$2(fs$4.lstat);
213
+
214
+ const typeMappings = {
215
+ directory: 'isDirectory',
216
+ file: 'isFile'
217
+ };
218
+
219
+ function checkType({type}) {
220
+ if (type in typeMappings) {
221
+ return;
222
+ }
223
+
224
+ throw new Error(`Invalid type specified: ${type}`);
225
+ }
226
+
227
+ const matchType = (type, stat) => type === undefined || stat[typeMappings[type]]();
228
+
229
+ locatePath.exports = async (paths, options) => {
230
+ options = {
231
+ cwd: process.cwd(),
232
+ type: 'file',
233
+ allowSymlinks: true,
234
+ ...options
235
+ };
236
+
237
+ checkType(options);
238
+
239
+ const statFn = options.allowSymlinks ? fsStat : fsLStat;
240
+
241
+ return pLocate(paths, async path_ => {
242
+ try {
243
+ const stat = await statFn(path$4.resolve(options.cwd, path_));
244
+ return matchType(options.type, stat);
245
+ } catch {
246
+ return false;
247
+ }
248
+ }, options);
249
+ };
250
+
251
+ locatePath.exports.sync = (paths, options) => {
252
+ options = {
253
+ cwd: process.cwd(),
254
+ allowSymlinks: true,
255
+ type: 'file',
256
+ ...options
257
+ };
258
+
259
+ checkType(options);
260
+
261
+ const statFn = options.allowSymlinks ? fs$4.statSync : fs$4.lstatSync;
262
+
263
+ for (const path_ of paths) {
264
+ try {
265
+ const stat = statFn(path$4.resolve(options.cwd, path_));
266
+
267
+ if (matchType(options.type, stat)) {
268
+ return path_;
269
+ }
270
+ } catch {}
271
+ }
272
+ };
273
+
274
+ var pathExists = {exports: {}};
275
+
276
+ const fs$3 = fs$5;
277
+ const {promisify: promisify$1} = require$$0;
278
+
279
+ const pAccess = promisify$1(fs$3.access);
280
+
281
+ pathExists.exports = async path => {
282
+ try {
283
+ await pAccess(path);
284
+ return true;
285
+ } catch (_) {
286
+ return false;
287
+ }
288
+ };
289
+
290
+ pathExists.exports.sync = path => {
291
+ try {
292
+ fs$3.accessSync(path);
293
+ return true;
294
+ } catch (_) {
295
+ return false;
296
+ }
297
+ };
298
+
299
+ (function (module) {
300
+ const path = path$5;
301
+ const locatePath$1 = locatePath.exports;
302
+ const pathExists$1 = pathExists.exports;
303
+
304
+ const stop = Symbol('findUp.stop');
305
+
306
+ module.exports = async (name, options = {}) => {
307
+ let directory = path.resolve(options.cwd || '');
308
+ const {root} = path.parse(directory);
309
+ const paths = [].concat(name);
310
+
311
+ const runMatcher = async locateOptions => {
312
+ if (typeof name !== 'function') {
313
+ return locatePath$1(paths, locateOptions);
314
+ }
315
+
316
+ const foundPath = await name(locateOptions.cwd);
317
+ if (typeof foundPath === 'string') {
318
+ return locatePath$1([foundPath], locateOptions);
319
+ }
320
+
321
+ return foundPath;
322
+ };
323
+
324
+ // eslint-disable-next-line no-constant-condition
325
+ while (true) {
326
+ // eslint-disable-next-line no-await-in-loop
327
+ const foundPath = await runMatcher({...options, cwd: directory});
328
+
329
+ if (foundPath === stop) {
330
+ return;
331
+ }
332
+
333
+ if (foundPath) {
334
+ return path.resolve(directory, foundPath);
335
+ }
336
+
337
+ if (directory === root) {
338
+ return;
339
+ }
340
+
341
+ directory = path.dirname(directory);
342
+ }
343
+ };
344
+
345
+ module.exports.sync = (name, options = {}) => {
346
+ let directory = path.resolve(options.cwd || '');
347
+ const {root} = path.parse(directory);
348
+ const paths = [].concat(name);
349
+
350
+ const runMatcher = locateOptions => {
351
+ if (typeof name !== 'function') {
352
+ return locatePath$1.sync(paths, locateOptions);
353
+ }
354
+
355
+ const foundPath = name(locateOptions.cwd);
356
+ if (typeof foundPath === 'string') {
357
+ return locatePath$1.sync([foundPath], locateOptions);
358
+ }
359
+
360
+ return foundPath;
361
+ };
362
+
363
+ // eslint-disable-next-line no-constant-condition
364
+ while (true) {
365
+ const foundPath = runMatcher({...options, cwd: directory});
366
+
367
+ if (foundPath === stop) {
368
+ return;
369
+ }
370
+
371
+ if (foundPath) {
372
+ return path.resolve(directory, foundPath);
373
+ }
374
+
375
+ if (directory === root) {
376
+ return;
377
+ }
378
+
379
+ directory = path.dirname(directory);
380
+ }
381
+ };
382
+
383
+ module.exports.exists = pathExists$1;
384
+
385
+ module.exports.sync.exists = pathExists$1.sync;
386
+
387
+ module.exports.stop = stop;
388
+ }(findUp$1));
389
+
390
+ var findUp = findUp$1.exports;
391
+
392
+ var execa$2 = {exports: {}};
393
+
394
+ var crossSpawn$1 = {exports: {}};
395
+
396
+ var windows = isexe$3;
397
+ isexe$3.sync = sync$2;
398
+
399
+ var fs$2 = fs$5;
400
+
401
+ function checkPathExt (path, options) {
402
+ var pathext = options.pathExt !== undefined ?
403
+ options.pathExt : process.env.PATHEXT;
404
+
405
+ if (!pathext) {
406
+ return true
407
+ }
408
+
409
+ pathext = pathext.split(';');
410
+ if (pathext.indexOf('') !== -1) {
411
+ return true
412
+ }
413
+ for (var i = 0; i < pathext.length; i++) {
414
+ var p = pathext[i].toLowerCase();
415
+ if (p && path.substr(-p.length).toLowerCase() === p) {
416
+ return true
417
+ }
418
+ }
419
+ return false
420
+ }
421
+
422
+ function checkStat$1 (stat, path, options) {
423
+ if (!stat.isSymbolicLink() && !stat.isFile()) {
424
+ return false
425
+ }
426
+ return checkPathExt(path, options)
427
+ }
428
+
429
+ function isexe$3 (path, options, cb) {
430
+ fs$2.stat(path, function (er, stat) {
431
+ cb(er, er ? false : checkStat$1(stat, path, options));
432
+ });
433
+ }
434
+
435
+ function sync$2 (path, options) {
436
+ return checkStat$1(fs$2.statSync(path), path, options)
437
+ }
438
+
439
+ var mode = isexe$2;
440
+ isexe$2.sync = sync$1;
441
+
442
+ var fs$1 = fs$5;
443
+
444
+ function isexe$2 (path, options, cb) {
445
+ fs$1.stat(path, function (er, stat) {
446
+ cb(er, er ? false : checkStat(stat, options));
447
+ });
448
+ }
449
+
450
+ function sync$1 (path, options) {
451
+ return checkStat(fs$1.statSync(path), options)
452
+ }
453
+
454
+ function checkStat (stat, options) {
455
+ return stat.isFile() && checkMode(stat, options)
456
+ }
457
+
458
+ function checkMode (stat, options) {
459
+ var mod = stat.mode;
460
+ var uid = stat.uid;
461
+ var gid = stat.gid;
462
+
463
+ var myUid = options.uid !== undefined ?
464
+ options.uid : process.getuid && process.getuid();
465
+ var myGid = options.gid !== undefined ?
466
+ options.gid : process.getgid && process.getgid();
467
+
468
+ var u = parseInt('100', 8);
469
+ var g = parseInt('010', 8);
470
+ var o = parseInt('001', 8);
471
+ var ug = u | g;
472
+
473
+ var ret = (mod & o) ||
474
+ (mod & g) && gid === myGid ||
475
+ (mod & u) && uid === myUid ||
476
+ (mod & ug) && myUid === 0;
477
+
478
+ return ret
479
+ }
480
+
481
+ var core$1;
482
+ if (process.platform === 'win32' || commonjsGlobal.TESTING_WINDOWS) {
483
+ core$1 = windows;
484
+ } else {
485
+ core$1 = mode;
486
+ }
487
+
488
+ var isexe_1 = isexe$1;
489
+ isexe$1.sync = sync;
490
+
491
+ function isexe$1 (path, options, cb) {
492
+ if (typeof options === 'function') {
493
+ cb = options;
494
+ options = {};
495
+ }
496
+
497
+ if (!cb) {
498
+ if (typeof Promise !== 'function') {
499
+ throw new TypeError('callback not provided')
500
+ }
501
+
502
+ return new Promise(function (resolve, reject) {
503
+ isexe$1(path, options || {}, function (er, is) {
504
+ if (er) {
505
+ reject(er);
506
+ } else {
507
+ resolve(is);
508
+ }
509
+ });
510
+ })
511
+ }
512
+
513
+ core$1(path, options || {}, function (er, is) {
514
+ // ignore EACCES because that just means we aren't allowed to run it
515
+ if (er) {
516
+ if (er.code === 'EACCES' || options && options.ignoreErrors) {
517
+ er = null;
518
+ is = false;
519
+ }
520
+ }
521
+ cb(er, is);
522
+ });
523
+ }
524
+
525
+ function sync (path, options) {
526
+ // my kingdom for a filtered catch
527
+ try {
528
+ return core$1.sync(path, options || {})
529
+ } catch (er) {
530
+ if (options && options.ignoreErrors || er.code === 'EACCES') {
531
+ return false
532
+ } else {
533
+ throw er
534
+ }
535
+ }
536
+ }
537
+
538
+ const isWindows = process.platform === 'win32' ||
539
+ process.env.OSTYPE === 'cygwin' ||
540
+ process.env.OSTYPE === 'msys';
541
+
542
+ const path$3 = path$5;
543
+ const COLON = isWindows ? ';' : ':';
544
+ const isexe = isexe_1;
545
+
546
+ const getNotFoundError = (cmd) =>
547
+ Object.assign(new Error(`not found: ${cmd}`), { code: 'ENOENT' });
548
+
549
+ const getPathInfo = (cmd, opt) => {
550
+ const colon = opt.colon || COLON;
551
+
552
+ // If it has a slash, then we don't bother searching the pathenv.
553
+ // just check the file itself, and that's it.
554
+ const pathEnv = cmd.match(/\//) || isWindows && cmd.match(/\\/) ? ['']
555
+ : (
556
+ [
557
+ // windows always checks the cwd first
558
+ ...(isWindows ? [process.cwd()] : []),
559
+ ...(opt.path || process.env.PATH ||
560
+ /* istanbul ignore next: very unusual */ '').split(colon),
561
+ ]
562
+ );
563
+ const pathExtExe = isWindows
564
+ ? opt.pathExt || process.env.PATHEXT || '.EXE;.CMD;.BAT;.COM'
565
+ : '';
566
+ const pathExt = isWindows ? pathExtExe.split(colon) : [''];
567
+
568
+ if (isWindows) {
569
+ if (cmd.indexOf('.') !== -1 && pathExt[0] !== '')
570
+ pathExt.unshift('');
571
+ }
572
+
573
+ return {
574
+ pathEnv,
575
+ pathExt,
576
+ pathExtExe,
577
+ }
578
+ };
579
+
580
+ const which$1 = (cmd, opt, cb) => {
581
+ if (typeof opt === 'function') {
582
+ cb = opt;
583
+ opt = {};
584
+ }
585
+ if (!opt)
586
+ opt = {};
587
+
588
+ const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
589
+ const found = [];
590
+
591
+ const step = i => new Promise((resolve, reject) => {
592
+ if (i === pathEnv.length)
593
+ return opt.all && found.length ? resolve(found)
594
+ : reject(getNotFoundError(cmd))
595
+
596
+ const ppRaw = pathEnv[i];
597
+ const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
598
+
599
+ const pCmd = path$3.join(pathPart, cmd);
600
+ const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd
601
+ : pCmd;
602
+
603
+ resolve(subStep(p, i, 0));
604
+ });
605
+
606
+ const subStep = (p, i, ii) => new Promise((resolve, reject) => {
607
+ if (ii === pathExt.length)
608
+ return resolve(step(i + 1))
609
+ const ext = pathExt[ii];
610
+ isexe(p + ext, { pathExt: pathExtExe }, (er, is) => {
611
+ if (!er && is) {
612
+ if (opt.all)
613
+ found.push(p + ext);
614
+ else
615
+ return resolve(p + ext)
616
+ }
617
+ return resolve(subStep(p, i, ii + 1))
618
+ });
619
+ });
620
+
621
+ return cb ? step(0).then(res => cb(null, res), cb) : step(0)
622
+ };
623
+
624
+ const whichSync = (cmd, opt) => {
625
+ opt = opt || {};
626
+
627
+ const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
628
+ const found = [];
629
+
630
+ for (let i = 0; i < pathEnv.length; i ++) {
631
+ const ppRaw = pathEnv[i];
632
+ const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
633
+
634
+ const pCmd = path$3.join(pathPart, cmd);
635
+ const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd
636
+ : pCmd;
637
+
638
+ for (let j = 0; j < pathExt.length; j ++) {
639
+ const cur = p + pathExt[j];
640
+ try {
641
+ const is = isexe.sync(cur, { pathExt: pathExtExe });
642
+ if (is) {
643
+ if (opt.all)
644
+ found.push(cur);
645
+ else
646
+ return cur
647
+ }
648
+ } catch (ex) {}
649
+ }
650
+ }
651
+
652
+ if (opt.all && found.length)
653
+ return found
654
+
655
+ if (opt.nothrow)
656
+ return null
657
+
658
+ throw getNotFoundError(cmd)
659
+ };
660
+
661
+ var which_1 = which$1;
662
+ which$1.sync = whichSync;
663
+
664
+ var pathKey$1 = {exports: {}};
665
+
666
+ const pathKey = (options = {}) => {
667
+ const environment = options.env || process.env;
668
+ const platform = options.platform || process.platform;
669
+
670
+ if (platform !== 'win32') {
671
+ return 'PATH';
672
+ }
673
+
674
+ return Object.keys(environment).reverse().find(key => key.toUpperCase() === 'PATH') || 'Path';
675
+ };
676
+
677
+ pathKey$1.exports = pathKey;
678
+ // TODO: Remove this for the next major release
679
+ pathKey$1.exports.default = pathKey;
680
+
681
+ const path$2 = path$5;
682
+ const which = which_1;
683
+ const getPathKey = pathKey$1.exports;
684
+
685
+ function resolveCommandAttempt(parsed, withoutPathExt) {
686
+ const env = parsed.options.env || process.env;
687
+ const cwd = process.cwd();
688
+ const hasCustomCwd = parsed.options.cwd != null;
689
+ // Worker threads do not have process.chdir()
690
+ const shouldSwitchCwd = hasCustomCwd && process.chdir !== undefined && !process.chdir.disabled;
691
+
692
+ // If a custom `cwd` was specified, we need to change the process cwd
693
+ // because `which` will do stat calls but does not support a custom cwd
694
+ if (shouldSwitchCwd) {
695
+ try {
696
+ process.chdir(parsed.options.cwd);
697
+ } catch (err) {
698
+ /* Empty */
699
+ }
700
+ }
701
+
702
+ let resolved;
703
+
704
+ try {
705
+ resolved = which.sync(parsed.command, {
706
+ path: env[getPathKey({ env })],
707
+ pathExt: withoutPathExt ? path$2.delimiter : undefined,
708
+ });
709
+ } catch (e) {
710
+ /* Empty */
711
+ } finally {
712
+ if (shouldSwitchCwd) {
713
+ process.chdir(cwd);
714
+ }
715
+ }
716
+
717
+ // If we successfully resolved, ensure that an absolute path is returned
718
+ // Note that when a custom `cwd` was used, we need to resolve to an absolute path based on it
719
+ if (resolved) {
720
+ resolved = path$2.resolve(hasCustomCwd ? parsed.options.cwd : '', resolved);
721
+ }
722
+
723
+ return resolved;
724
+ }
725
+
726
+ function resolveCommand$1(parsed) {
727
+ return resolveCommandAttempt(parsed) || resolveCommandAttempt(parsed, true);
728
+ }
729
+
730
+ var resolveCommand_1 = resolveCommand$1;
731
+
732
+ var _escape = {};
733
+
734
+ // See http://www.robvanderwoude.com/escapechars.php
735
+ const metaCharsRegExp = /([()\][%!^"`<>&|;, *?])/g;
736
+
737
+ function escapeCommand(arg) {
738
+ // Escape meta chars
739
+ arg = arg.replace(metaCharsRegExp, '^$1');
740
+
741
+ return arg;
742
+ }
743
+
744
+ function escapeArgument(arg, doubleEscapeMetaChars) {
745
+ // Convert to string
746
+ arg = `${arg}`;
747
+
748
+ // Algorithm below is based on https://qntm.org/cmd
749
+
750
+ // Sequence of backslashes followed by a double quote:
751
+ // double up all the backslashes and escape the double quote
752
+ arg = arg.replace(/(\\*)"/g, '$1$1\\"');
753
+
754
+ // Sequence of backslashes followed by the end of the string
755
+ // (which will become a double quote later):
756
+ // double up all the backslashes
757
+ arg = arg.replace(/(\\*)$/, '$1$1');
758
+
759
+ // All other backslashes occur literally
760
+
761
+ // Quote the whole thing:
762
+ arg = `"${arg}"`;
763
+
764
+ // Escape meta chars
765
+ arg = arg.replace(metaCharsRegExp, '^$1');
766
+
767
+ // Double escape meta chars if necessary
768
+ if (doubleEscapeMetaChars) {
769
+ arg = arg.replace(metaCharsRegExp, '^$1');
770
+ }
771
+
772
+ return arg;
773
+ }
774
+
775
+ _escape.command = escapeCommand;
776
+ _escape.argument = escapeArgument;
777
+
778
+ var shebangRegex$1 = /^#!(.*)/;
779
+
780
+ const shebangRegex = shebangRegex$1;
781
+
782
+ var shebangCommand$1 = (string = '') => {
783
+ const match = string.match(shebangRegex);
784
+
785
+ if (!match) {
786
+ return null;
787
+ }
788
+
789
+ const [path, argument] = match[0].replace(/#! ?/, '').split(' ');
790
+ const binary = path.split('/').pop();
791
+
792
+ if (binary === 'env') {
793
+ return argument;
794
+ }
795
+
796
+ return argument ? `${binary} ${argument}` : binary;
797
+ };
798
+
799
+ const fs = fs$5;
800
+ const shebangCommand = shebangCommand$1;
801
+
802
+ function readShebang$1(command) {
803
+ // Read the first 150 bytes from the file
804
+ const size = 150;
805
+ const buffer = Buffer.alloc(size);
806
+
807
+ let fd;
808
+
809
+ try {
810
+ fd = fs.openSync(command, 'r');
811
+ fs.readSync(fd, buffer, 0, size, 0);
812
+ fs.closeSync(fd);
813
+ } catch (e) { /* Empty */ }
814
+
815
+ // Attempt to extract shebang (null is returned if not a shebang)
816
+ return shebangCommand(buffer.toString());
817
+ }
818
+
819
+ var readShebang_1 = readShebang$1;
820
+
821
+ const path$1 = path$5;
822
+ const resolveCommand = resolveCommand_1;
823
+ const escape = _escape;
824
+ const readShebang = readShebang_1;
825
+
826
+ const isWin$1 = process.platform === 'win32';
827
+ const isExecutableRegExp = /\.(?:com|exe)$/i;
828
+ const isCmdShimRegExp = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
829
+
830
+ function detectShebang(parsed) {
831
+ parsed.file = resolveCommand(parsed);
832
+
833
+ const shebang = parsed.file && readShebang(parsed.file);
834
+
835
+ if (shebang) {
836
+ parsed.args.unshift(parsed.file);
837
+ parsed.command = shebang;
838
+
839
+ return resolveCommand(parsed);
840
+ }
841
+
842
+ return parsed.file;
843
+ }
844
+
845
+ function parseNonShell(parsed) {
846
+ if (!isWin$1) {
847
+ return parsed;
848
+ }
849
+
850
+ // Detect & add support for shebangs
851
+ const commandFile = detectShebang(parsed);
852
+
853
+ // We don't need a shell if the command filename is an executable
854
+ const needsShell = !isExecutableRegExp.test(commandFile);
855
+
856
+ // If a shell is required, use cmd.exe and take care of escaping everything correctly
857
+ // Note that `forceShell` is an hidden option used only in tests
858
+ if (parsed.options.forceShell || needsShell) {
859
+ // Need to double escape meta chars if the command is a cmd-shim located in `node_modules/.bin/`
860
+ // The cmd-shim simply calls execute the package bin file with NodeJS, proxying any argument
861
+ // Because the escape of metachars with ^ gets interpreted when the cmd.exe is first called,
862
+ // we need to double escape them
863
+ const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
864
+
865
+ // Normalize posix paths into OS compatible paths (e.g.: foo/bar -> foo\bar)
866
+ // This is necessary otherwise it will always fail with ENOENT in those cases
867
+ parsed.command = path$1.normalize(parsed.command);
868
+
869
+ // Escape command & arguments
870
+ parsed.command = escape.command(parsed.command);
871
+ parsed.args = parsed.args.map((arg) => escape.argument(arg, needsDoubleEscapeMetaChars));
872
+
873
+ const shellCommand = [parsed.command].concat(parsed.args).join(' ');
874
+
875
+ parsed.args = ['/d', '/s', '/c', `"${shellCommand}"`];
876
+ parsed.command = process.env.comspec || 'cmd.exe';
877
+ parsed.options.windowsVerbatimArguments = true; // Tell node's spawn that the arguments are already escaped
878
+ }
879
+
880
+ return parsed;
881
+ }
882
+
883
+ function parse$1(command, args, options) {
884
+ // Normalize arguments, similar to nodejs
885
+ if (args && !Array.isArray(args)) {
886
+ options = args;
887
+ args = null;
888
+ }
889
+
890
+ args = args ? args.slice(0) : []; // Clone array to avoid changing the original
891
+ options = Object.assign({}, options); // Clone object to avoid changing the original
892
+
893
+ // Build our parsed object
894
+ const parsed = {
895
+ command,
896
+ args,
897
+ options,
898
+ file: undefined,
899
+ original: {
900
+ command,
901
+ args,
902
+ },
903
+ };
904
+
905
+ // Delegate further parsing to shell or non-shell
906
+ return options.shell ? parsed : parseNonShell(parsed);
907
+ }
908
+
909
+ var parse_1 = parse$1;
910
+
911
+ const isWin = process.platform === 'win32';
912
+
913
+ function notFoundError(original, syscall) {
914
+ return Object.assign(new Error(`${syscall} ${original.command} ENOENT`), {
915
+ code: 'ENOENT',
916
+ errno: 'ENOENT',
917
+ syscall: `${syscall} ${original.command}`,
918
+ path: original.command,
919
+ spawnargs: original.args,
920
+ });
921
+ }
922
+
923
+ function hookChildProcess(cp, parsed) {
924
+ if (!isWin) {
925
+ return;
926
+ }
927
+
928
+ const originalEmit = cp.emit;
929
+
930
+ cp.emit = function (name, arg1) {
931
+ // If emitting "exit" event and exit code is 1, we need to check if
932
+ // the command exists and emit an "error" instead
933
+ // See https://github.com/IndigoUnited/node-cross-spawn/issues/16
934
+ if (name === 'exit') {
935
+ const err = verifyENOENT(arg1, parsed);
936
+
937
+ if (err) {
938
+ return originalEmit.call(cp, 'error', err);
939
+ }
940
+ }
941
+
942
+ return originalEmit.apply(cp, arguments); // eslint-disable-line prefer-rest-params
943
+ };
944
+ }
945
+
946
+ function verifyENOENT(status, parsed) {
947
+ if (isWin && status === 1 && !parsed.file) {
948
+ return notFoundError(parsed.original, 'spawn');
949
+ }
950
+
951
+ return null;
952
+ }
953
+
954
+ function verifyENOENTSync(status, parsed) {
955
+ if (isWin && status === 1 && !parsed.file) {
956
+ return notFoundError(parsed.original, 'spawnSync');
957
+ }
958
+
959
+ return null;
960
+ }
961
+
962
+ var enoent$1 = {
963
+ hookChildProcess,
964
+ verifyENOENT,
965
+ verifyENOENTSync,
966
+ notFoundError,
967
+ };
968
+
969
+ const cp = require$$0$1;
970
+ const parse = parse_1;
971
+ const enoent = enoent$1;
972
+
973
+ function spawn(command, args, options) {
974
+ // Parse the arguments
975
+ const parsed = parse(command, args, options);
976
+
977
+ // Spawn the child process
978
+ const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);
979
+
980
+ // Hook into child process "exit" event to emit an error if the command
981
+ // does not exists, see: https://github.com/IndigoUnited/node-cross-spawn/issues/16
982
+ enoent.hookChildProcess(spawned, parsed);
983
+
984
+ return spawned;
985
+ }
986
+
987
+ function spawnSync(command, args, options) {
988
+ // Parse the arguments
989
+ const parsed = parse(command, args, options);
990
+
991
+ // Spawn the child process
992
+ const result = cp.spawnSync(parsed.command, parsed.args, parsed.options);
993
+
994
+ // Analyze if the command does not exist, see: https://github.com/IndigoUnited/node-cross-spawn/issues/16
995
+ result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
996
+
997
+ return result;
998
+ }
999
+
1000
+ crossSpawn$1.exports = spawn;
1001
+ crossSpawn$1.exports.spawn = spawn;
1002
+ crossSpawn$1.exports.sync = spawnSync;
1003
+
1004
+ crossSpawn$1.exports._parse = parse;
1005
+ crossSpawn$1.exports._enoent = enoent;
1006
+
1007
+ var stripFinalNewline$1 = input => {
1008
+ const LF = typeof input === 'string' ? '\n' : '\n'.charCodeAt();
1009
+ const CR = typeof input === 'string' ? '\r' : '\r'.charCodeAt();
1010
+
1011
+ if (input[input.length - 1] === LF) {
1012
+ input = input.slice(0, input.length - 1);
1013
+ }
1014
+
1015
+ if (input[input.length - 1] === CR) {
1016
+ input = input.slice(0, input.length - 1);
1017
+ }
1018
+
1019
+ return input;
1020
+ };
1021
+
1022
+ var npmRunPath$1 = {exports: {}};
1023
+
1024
+ (function (module) {
1025
+ const path = path$5;
1026
+ const pathKey = pathKey$1.exports;
1027
+
1028
+ const npmRunPath = options => {
1029
+ options = {
1030
+ cwd: process.cwd(),
1031
+ path: process.env[pathKey()],
1032
+ execPath: process.execPath,
1033
+ ...options
1034
+ };
1035
+
1036
+ let previous;
1037
+ let cwdPath = path.resolve(options.cwd);
1038
+ const result = [];
1039
+
1040
+ while (previous !== cwdPath) {
1041
+ result.push(path.join(cwdPath, 'node_modules/.bin'));
1042
+ previous = cwdPath;
1043
+ cwdPath = path.resolve(cwdPath, '..');
1044
+ }
1045
+
1046
+ // Ensure the running `node` binary is used
1047
+ const execPathDir = path.resolve(options.cwd, options.execPath, '..');
1048
+ result.push(execPathDir);
1049
+
1050
+ return result.concat(options.path).join(path.delimiter);
1051
+ };
1052
+
1053
+ module.exports = npmRunPath;
1054
+ // TODO: Remove this for the next major release
1055
+ module.exports.default = npmRunPath;
1056
+
1057
+ module.exports.env = options => {
1058
+ options = {
1059
+ env: process.env,
1060
+ ...options
1061
+ };
1062
+
1063
+ const env = {...options.env};
1064
+ const path = pathKey({env});
1065
+
1066
+ options.path = env[path];
1067
+ env[path] = module.exports(options);
1068
+
1069
+ return env;
1070
+ };
1071
+ }(npmRunPath$1));
1072
+
1073
+ var main = {};
1074
+
1075
+ var signals = {};
1076
+
1077
+ var core = {};
1078
+
1079
+ Object.defineProperty(core,"__esModule",{value:true});core.SIGNALS=void 0;
1080
+
1081
+ const SIGNALS=[
1082
+ {
1083
+ name:"SIGHUP",
1084
+ number:1,
1085
+ action:"terminate",
1086
+ description:"Terminal closed",
1087
+ standard:"posix"},
1088
+
1089
+ {
1090
+ name:"SIGINT",
1091
+ number:2,
1092
+ action:"terminate",
1093
+ description:"User interruption with CTRL-C",
1094
+ standard:"ansi"},
1095
+
1096
+ {
1097
+ name:"SIGQUIT",
1098
+ number:3,
1099
+ action:"core",
1100
+ description:"User interruption with CTRL-\\",
1101
+ standard:"posix"},
1102
+
1103
+ {
1104
+ name:"SIGILL",
1105
+ number:4,
1106
+ action:"core",
1107
+ description:"Invalid machine instruction",
1108
+ standard:"ansi"},
1109
+
1110
+ {
1111
+ name:"SIGTRAP",
1112
+ number:5,
1113
+ action:"core",
1114
+ description:"Debugger breakpoint",
1115
+ standard:"posix"},
1116
+
1117
+ {
1118
+ name:"SIGABRT",
1119
+ number:6,
1120
+ action:"core",
1121
+ description:"Aborted",
1122
+ standard:"ansi"},
1123
+
1124
+ {
1125
+ name:"SIGIOT",
1126
+ number:6,
1127
+ action:"core",
1128
+ description:"Aborted",
1129
+ standard:"bsd"},
1130
+
1131
+ {
1132
+ name:"SIGBUS",
1133
+ number:7,
1134
+ action:"core",
1135
+ description:
1136
+ "Bus error due to misaligned, non-existing address or paging error",
1137
+ standard:"bsd"},
1138
+
1139
+ {
1140
+ name:"SIGEMT",
1141
+ number:7,
1142
+ action:"terminate",
1143
+ description:"Command should be emulated but is not implemented",
1144
+ standard:"other"},
1145
+
1146
+ {
1147
+ name:"SIGFPE",
1148
+ number:8,
1149
+ action:"core",
1150
+ description:"Floating point arithmetic error",
1151
+ standard:"ansi"},
1152
+
1153
+ {
1154
+ name:"SIGKILL",
1155
+ number:9,
1156
+ action:"terminate",
1157
+ description:"Forced termination",
1158
+ standard:"posix",
1159
+ forced:true},
1160
+
1161
+ {
1162
+ name:"SIGUSR1",
1163
+ number:10,
1164
+ action:"terminate",
1165
+ description:"Application-specific signal",
1166
+ standard:"posix"},
1167
+
1168
+ {
1169
+ name:"SIGSEGV",
1170
+ number:11,
1171
+ action:"core",
1172
+ description:"Segmentation fault",
1173
+ standard:"ansi"},
1174
+
1175
+ {
1176
+ name:"SIGUSR2",
1177
+ number:12,
1178
+ action:"terminate",
1179
+ description:"Application-specific signal",
1180
+ standard:"posix"},
1181
+
1182
+ {
1183
+ name:"SIGPIPE",
1184
+ number:13,
1185
+ action:"terminate",
1186
+ description:"Broken pipe or socket",
1187
+ standard:"posix"},
1188
+
1189
+ {
1190
+ name:"SIGALRM",
1191
+ number:14,
1192
+ action:"terminate",
1193
+ description:"Timeout or timer",
1194
+ standard:"posix"},
1195
+
1196
+ {
1197
+ name:"SIGTERM",
1198
+ number:15,
1199
+ action:"terminate",
1200
+ description:"Termination",
1201
+ standard:"ansi"},
1202
+
1203
+ {
1204
+ name:"SIGSTKFLT",
1205
+ number:16,
1206
+ action:"terminate",
1207
+ description:"Stack is empty or overflowed",
1208
+ standard:"other"},
1209
+
1210
+ {
1211
+ name:"SIGCHLD",
1212
+ number:17,
1213
+ action:"ignore",
1214
+ description:"Child process terminated, paused or unpaused",
1215
+ standard:"posix"},
1216
+
1217
+ {
1218
+ name:"SIGCLD",
1219
+ number:17,
1220
+ action:"ignore",
1221
+ description:"Child process terminated, paused or unpaused",
1222
+ standard:"other"},
1223
+
1224
+ {
1225
+ name:"SIGCONT",
1226
+ number:18,
1227
+ action:"unpause",
1228
+ description:"Unpaused",
1229
+ standard:"posix",
1230
+ forced:true},
1231
+
1232
+ {
1233
+ name:"SIGSTOP",
1234
+ number:19,
1235
+ action:"pause",
1236
+ description:"Paused",
1237
+ standard:"posix",
1238
+ forced:true},
1239
+
1240
+ {
1241
+ name:"SIGTSTP",
1242
+ number:20,
1243
+ action:"pause",
1244
+ description:"Paused using CTRL-Z or \"suspend\"",
1245
+ standard:"posix"},
1246
+
1247
+ {
1248
+ name:"SIGTTIN",
1249
+ number:21,
1250
+ action:"pause",
1251
+ description:"Background process cannot read terminal input",
1252
+ standard:"posix"},
1253
+
1254
+ {
1255
+ name:"SIGBREAK",
1256
+ number:21,
1257
+ action:"terminate",
1258
+ description:"User interruption with CTRL-BREAK",
1259
+ standard:"other"},
1260
+
1261
+ {
1262
+ name:"SIGTTOU",
1263
+ number:22,
1264
+ action:"pause",
1265
+ description:"Background process cannot write to terminal output",
1266
+ standard:"posix"},
1267
+
1268
+ {
1269
+ name:"SIGURG",
1270
+ number:23,
1271
+ action:"ignore",
1272
+ description:"Socket received out-of-band data",
1273
+ standard:"bsd"},
1274
+
1275
+ {
1276
+ name:"SIGXCPU",
1277
+ number:24,
1278
+ action:"core",
1279
+ description:"Process timed out",
1280
+ standard:"bsd"},
1281
+
1282
+ {
1283
+ name:"SIGXFSZ",
1284
+ number:25,
1285
+ action:"core",
1286
+ description:"File too big",
1287
+ standard:"bsd"},
1288
+
1289
+ {
1290
+ name:"SIGVTALRM",
1291
+ number:26,
1292
+ action:"terminate",
1293
+ description:"Timeout or timer",
1294
+ standard:"bsd"},
1295
+
1296
+ {
1297
+ name:"SIGPROF",
1298
+ number:27,
1299
+ action:"terminate",
1300
+ description:"Timeout or timer",
1301
+ standard:"bsd"},
1302
+
1303
+ {
1304
+ name:"SIGWINCH",
1305
+ number:28,
1306
+ action:"ignore",
1307
+ description:"Terminal window size changed",
1308
+ standard:"bsd"},
1309
+
1310
+ {
1311
+ name:"SIGIO",
1312
+ number:29,
1313
+ action:"terminate",
1314
+ description:"I/O is available",
1315
+ standard:"other"},
1316
+
1317
+ {
1318
+ name:"SIGPOLL",
1319
+ number:29,
1320
+ action:"terminate",
1321
+ description:"Watched event",
1322
+ standard:"other"},
1323
+
1324
+ {
1325
+ name:"SIGINFO",
1326
+ number:29,
1327
+ action:"ignore",
1328
+ description:"Request for process information",
1329
+ standard:"other"},
1330
+
1331
+ {
1332
+ name:"SIGPWR",
1333
+ number:30,
1334
+ action:"terminate",
1335
+ description:"Device running out of power",
1336
+ standard:"systemv"},
1337
+
1338
+ {
1339
+ name:"SIGSYS",
1340
+ number:31,
1341
+ action:"core",
1342
+ description:"Invalid system call",
1343
+ standard:"other"},
1344
+
1345
+ {
1346
+ name:"SIGUNUSED",
1347
+ number:31,
1348
+ action:"terminate",
1349
+ description:"Invalid system call",
1350
+ standard:"other"}];core.SIGNALS=SIGNALS;
1351
+
1352
+ var realtime = {};
1353
+
1354
+ Object.defineProperty(realtime,"__esModule",{value:true});realtime.SIGRTMAX=realtime.getRealtimeSignals=void 0;
1355
+ const getRealtimeSignals=function(){
1356
+ const length=SIGRTMAX-SIGRTMIN+1;
1357
+ return Array.from({length},getRealtimeSignal);
1358
+ };realtime.getRealtimeSignals=getRealtimeSignals;
1359
+
1360
+ const getRealtimeSignal=function(value,index){
1361
+ return {
1362
+ name:`SIGRT${index+1}`,
1363
+ number:SIGRTMIN+index,
1364
+ action:"terminate",
1365
+ description:"Application-specific signal (realtime)",
1366
+ standard:"posix"};
1367
+
1368
+ };
1369
+
1370
+ const SIGRTMIN=34;
1371
+ const SIGRTMAX=64;realtime.SIGRTMAX=SIGRTMAX;
1372
+
1373
+ Object.defineProperty(signals,"__esModule",{value:true});signals.getSignals=void 0;var _os$1=require$$0$2;
1374
+
1375
+ var _core=core;
1376
+ var _realtime$1=realtime;
1377
+
1378
+
1379
+
1380
+ const getSignals=function(){
1381
+ const realtimeSignals=(0, _realtime$1.getRealtimeSignals)();
1382
+ const signals=[..._core.SIGNALS,...realtimeSignals].map(normalizeSignal);
1383
+ return signals;
1384
+ };signals.getSignals=getSignals;
1385
+
1386
+
1387
+
1388
+
1389
+
1390
+
1391
+
1392
+ const normalizeSignal=function({
1393
+ name,
1394
+ number:defaultNumber,
1395
+ description,
1396
+ action,
1397
+ forced=false,
1398
+ standard})
1399
+ {
1400
+ const{
1401
+ signals:{[name]:constantSignal}}=
1402
+ _os$1.constants;
1403
+ const supported=constantSignal!==undefined;
1404
+ const number=supported?constantSignal:defaultNumber;
1405
+ return {name,number,description,supported,action,forced,standard};
1406
+ };
1407
+
1408
+ Object.defineProperty(main,"__esModule",{value:true});main.signalsByNumber=main.signalsByName=void 0;var _os=require$$0$2;
1409
+
1410
+ var _signals=signals;
1411
+ var _realtime=realtime;
1412
+
1413
+
1414
+
1415
+ const getSignalsByName=function(){
1416
+ const signals=(0, _signals.getSignals)();
1417
+ return signals.reduce(getSignalByName,{});
1418
+ };
1419
+
1420
+ const getSignalByName=function(
1421
+ signalByNameMemo,
1422
+ {name,number,description,supported,action,forced,standard})
1423
+ {
1424
+ return {
1425
+ ...signalByNameMemo,
1426
+ [name]:{name,number,description,supported,action,forced,standard}};
1427
+
1428
+ };
1429
+
1430
+ const signalsByName$1=getSignalsByName();main.signalsByName=signalsByName$1;
1431
+
1432
+
1433
+
1434
+
1435
+ const getSignalsByNumber=function(){
1436
+ const signals=(0, _signals.getSignals)();
1437
+ const length=_realtime.SIGRTMAX+1;
1438
+ const signalsA=Array.from({length},(value,number)=>
1439
+ getSignalByNumber(number,signals));
1440
+
1441
+ return Object.assign({},...signalsA);
1442
+ };
1443
+
1444
+ const getSignalByNumber=function(number,signals){
1445
+ const signal=findSignalByNumber(number,signals);
1446
+
1447
+ if(signal===undefined){
1448
+ return {};
1449
+ }
1450
+
1451
+ const{name,description,supported,action,forced,standard}=signal;
1452
+ return {
1453
+ [number]:{
1454
+ name,
1455
+ number,
1456
+ description,
1457
+ supported,
1458
+ action,
1459
+ forced,
1460
+ standard}};
1461
+
1462
+
1463
+ };
1464
+
1465
+
1466
+
1467
+ const findSignalByNumber=function(number,signals){
1468
+ const signal=signals.find(({name})=>_os.constants.signals[name]===number);
1469
+
1470
+ if(signal!==undefined){
1471
+ return signal;
1472
+ }
1473
+
1474
+ return signals.find(signalA=>signalA.number===number);
1475
+ };
1476
+
1477
+ const signalsByNumber=getSignalsByNumber();main.signalsByNumber=signalsByNumber;
1478
+
1479
+ const {signalsByName} = main;
1480
+
1481
+ const getErrorPrefix = ({timedOut, timeout, errorCode, signal, signalDescription, exitCode, isCanceled}) => {
1482
+ if (timedOut) {
1483
+ return `timed out after ${timeout} milliseconds`;
1484
+ }
1485
+
1486
+ if (isCanceled) {
1487
+ return 'was canceled';
1488
+ }
1489
+
1490
+ if (errorCode !== undefined) {
1491
+ return `failed with ${errorCode}`;
1492
+ }
1493
+
1494
+ if (signal !== undefined) {
1495
+ return `was killed with ${signal} (${signalDescription})`;
1496
+ }
1497
+
1498
+ if (exitCode !== undefined) {
1499
+ return `failed with exit code ${exitCode}`;
1500
+ }
1501
+
1502
+ return 'failed';
1503
+ };
1504
+
1505
+ const makeError$1 = ({
1506
+ stdout,
1507
+ stderr,
1508
+ all,
1509
+ error,
1510
+ signal,
1511
+ exitCode,
1512
+ command,
1513
+ escapedCommand,
1514
+ timedOut,
1515
+ isCanceled,
1516
+ killed,
1517
+ parsed: {options: {timeout}}
1518
+ }) => {
1519
+ // `signal` and `exitCode` emitted on `spawned.on('exit')` event can be `null`.
1520
+ // We normalize them to `undefined`
1521
+ exitCode = exitCode === null ? undefined : exitCode;
1522
+ signal = signal === null ? undefined : signal;
1523
+ const signalDescription = signal === undefined ? undefined : signalsByName[signal].description;
1524
+
1525
+ const errorCode = error && error.code;
1526
+
1527
+ const prefix = getErrorPrefix({timedOut, timeout, errorCode, signal, signalDescription, exitCode, isCanceled});
1528
+ const execaMessage = `Command ${prefix}: ${command}`;
1529
+ const isError = Object.prototype.toString.call(error) === '[object Error]';
1530
+ const shortMessage = isError ? `${execaMessage}\n${error.message}` : execaMessage;
1531
+ const message = [shortMessage, stderr, stdout].filter(Boolean).join('\n');
1532
+
1533
+ if (isError) {
1534
+ error.originalMessage = error.message;
1535
+ error.message = message;
1536
+ } else {
1537
+ error = new Error(message);
1538
+ }
1539
+
1540
+ error.shortMessage = shortMessage;
1541
+ error.command = command;
1542
+ error.escapedCommand = escapedCommand;
1543
+ error.exitCode = exitCode;
1544
+ error.signal = signal;
1545
+ error.signalDescription = signalDescription;
1546
+ error.stdout = stdout;
1547
+ error.stderr = stderr;
1548
+
1549
+ if (all !== undefined) {
1550
+ error.all = all;
1551
+ }
1552
+
1553
+ if ('bufferedData' in error) {
1554
+ delete error.bufferedData;
1555
+ }
1556
+
1557
+ error.failed = true;
1558
+ error.timedOut = Boolean(timedOut);
1559
+ error.isCanceled = isCanceled;
1560
+ error.killed = killed && !timedOut;
1561
+
1562
+ return error;
1563
+ };
1564
+
1565
+ var error = makeError$1;
1566
+
1567
+ var stdio = {exports: {}};
1568
+
1569
+ const aliases = ['stdin', 'stdout', 'stderr'];
1570
+
1571
+ const hasAlias = options => aliases.some(alias => options[alias] !== undefined);
1572
+
1573
+ const normalizeStdio$1 = options => {
1574
+ if (!options) {
1575
+ return;
1576
+ }
1577
+
1578
+ const {stdio} = options;
1579
+
1580
+ if (stdio === undefined) {
1581
+ return aliases.map(alias => options[alias]);
1582
+ }
1583
+
1584
+ if (hasAlias(options)) {
1585
+ throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${aliases.map(alias => `\`${alias}\``).join(', ')}`);
1586
+ }
1587
+
1588
+ if (typeof stdio === 'string') {
1589
+ return stdio;
1590
+ }
1591
+
1592
+ if (!Array.isArray(stdio)) {
1593
+ throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof stdio}\``);
1594
+ }
1595
+
1596
+ const length = Math.max(stdio.length, aliases.length);
1597
+ return Array.from({length}, (value, index) => stdio[index]);
1598
+ };
1599
+
1600
+ stdio.exports = normalizeStdio$1;
1601
+
1602
+ // `ipc` is pushed unless it is already present
1603
+ stdio.exports.node = options => {
1604
+ const stdio = normalizeStdio$1(options);
1605
+
1606
+ if (stdio === 'ipc') {
1607
+ return 'ipc';
1608
+ }
1609
+
1610
+ if (stdio === undefined || typeof stdio === 'string') {
1611
+ return [stdio, stdio, stdio, 'ipc'];
1612
+ }
1613
+
1614
+ if (stdio.includes('ipc')) {
1615
+ return stdio;
1616
+ }
1617
+
1618
+ return [...stdio, 'ipc'];
1619
+ };
1620
+
1621
+ const os = require$$0$2;
1622
+ const onExit = signalExit.exports;
1623
+
1624
+ const DEFAULT_FORCE_KILL_TIMEOUT = 1000 * 5;
1625
+
1626
+ // Monkey-patches `childProcess.kill()` to add `forceKillAfterTimeout` behavior
1627
+ const spawnedKill$1 = (kill, signal = 'SIGTERM', options = {}) => {
1628
+ const killResult = kill(signal);
1629
+ setKillTimeout(kill, signal, options, killResult);
1630
+ return killResult;
1631
+ };
1632
+
1633
+ const setKillTimeout = (kill, signal, options, killResult) => {
1634
+ if (!shouldForceKill(signal, options, killResult)) {
1635
+ return;
1636
+ }
1637
+
1638
+ const timeout = getForceKillAfterTimeout(options);
1639
+ const t = setTimeout(() => {
1640
+ kill('SIGKILL');
1641
+ }, timeout);
1642
+
1643
+ // Guarded because there's no `.unref()` when `execa` is used in the renderer
1644
+ // process in Electron. This cannot be tested since we don't run tests in
1645
+ // Electron.
1646
+ // istanbul ignore else
1647
+ if (t.unref) {
1648
+ t.unref();
1649
+ }
1650
+ };
1651
+
1652
+ const shouldForceKill = (signal, {forceKillAfterTimeout}, killResult) => {
1653
+ return isSigterm(signal) && forceKillAfterTimeout !== false && killResult;
1654
+ };
1655
+
1656
+ const isSigterm = signal => {
1657
+ return signal === os.constants.signals.SIGTERM ||
1658
+ (typeof signal === 'string' && signal.toUpperCase() === 'SIGTERM');
1659
+ };
1660
+
1661
+ const getForceKillAfterTimeout = ({forceKillAfterTimeout = true}) => {
1662
+ if (forceKillAfterTimeout === true) {
1663
+ return DEFAULT_FORCE_KILL_TIMEOUT;
1664
+ }
1665
+
1666
+ if (!Number.isFinite(forceKillAfterTimeout) || forceKillAfterTimeout < 0) {
1667
+ throw new TypeError(`Expected the \`forceKillAfterTimeout\` option to be a non-negative integer, got \`${forceKillAfterTimeout}\` (${typeof forceKillAfterTimeout})`);
1668
+ }
1669
+
1670
+ return forceKillAfterTimeout;
1671
+ };
1672
+
1673
+ // `childProcess.cancel()`
1674
+ const spawnedCancel$1 = (spawned, context) => {
1675
+ const killResult = spawned.kill();
1676
+
1677
+ if (killResult) {
1678
+ context.isCanceled = true;
1679
+ }
1680
+ };
1681
+
1682
+ const timeoutKill = (spawned, signal, reject) => {
1683
+ spawned.kill(signal);
1684
+ reject(Object.assign(new Error('Timed out'), {timedOut: true, signal}));
1685
+ };
1686
+
1687
+ // `timeout` option handling
1688
+ const setupTimeout$1 = (spawned, {timeout, killSignal = 'SIGTERM'}, spawnedPromise) => {
1689
+ if (timeout === 0 || timeout === undefined) {
1690
+ return spawnedPromise;
1691
+ }
1692
+
1693
+ let timeoutId;
1694
+ const timeoutPromise = new Promise((resolve, reject) => {
1695
+ timeoutId = setTimeout(() => {
1696
+ timeoutKill(spawned, killSignal, reject);
1697
+ }, timeout);
1698
+ });
1699
+
1700
+ const safeSpawnedPromise = spawnedPromise.finally(() => {
1701
+ clearTimeout(timeoutId);
1702
+ });
1703
+
1704
+ return Promise.race([timeoutPromise, safeSpawnedPromise]);
1705
+ };
1706
+
1707
+ const validateTimeout$1 = ({timeout}) => {
1708
+ if (timeout !== undefined && (!Number.isFinite(timeout) || timeout < 0)) {
1709
+ throw new TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${timeout}\` (${typeof timeout})`);
1710
+ }
1711
+ };
1712
+
1713
+ // `cleanup` option handling
1714
+ const setExitHandler$1 = async (spawned, {cleanup, detached}, timedPromise) => {
1715
+ if (!cleanup || detached) {
1716
+ return timedPromise;
1717
+ }
1718
+
1719
+ const removeExitHandler = onExit(() => {
1720
+ spawned.kill();
1721
+ });
1722
+
1723
+ return timedPromise.finally(() => {
1724
+ removeExitHandler();
1725
+ });
1726
+ };
1727
+
1728
+ var kill = {
1729
+ spawnedKill: spawnedKill$1,
1730
+ spawnedCancel: spawnedCancel$1,
1731
+ setupTimeout: setupTimeout$1,
1732
+ validateTimeout: validateTimeout$1,
1733
+ setExitHandler: setExitHandler$1
1734
+ };
1735
+
1736
+ const isStream$1 = stream =>
1737
+ stream !== null &&
1738
+ typeof stream === 'object' &&
1739
+ typeof stream.pipe === 'function';
1740
+
1741
+ isStream$1.writable = stream =>
1742
+ isStream$1(stream) &&
1743
+ stream.writable !== false &&
1744
+ typeof stream._write === 'function' &&
1745
+ typeof stream._writableState === 'object';
1746
+
1747
+ isStream$1.readable = stream =>
1748
+ isStream$1(stream) &&
1749
+ stream.readable !== false &&
1750
+ typeof stream._read === 'function' &&
1751
+ typeof stream._readableState === 'object';
1752
+
1753
+ isStream$1.duplex = stream =>
1754
+ isStream$1.writable(stream) &&
1755
+ isStream$1.readable(stream);
1756
+
1757
+ isStream$1.transform = stream =>
1758
+ isStream$1.duplex(stream) &&
1759
+ typeof stream._transform === 'function';
1760
+
1761
+ var isStream_1 = isStream$1;
1762
+
1763
+ var getStream$2 = {exports: {}};
1764
+
1765
+ const {PassThrough: PassThroughStream} = require$$0$3;
1766
+
1767
+ var bufferStream$1 = options => {
1768
+ options = {...options};
1769
+
1770
+ const {array} = options;
1771
+ let {encoding} = options;
1772
+ const isBuffer = encoding === 'buffer';
1773
+ let objectMode = false;
1774
+
1775
+ if (array) {
1776
+ objectMode = !(encoding || isBuffer);
1777
+ } else {
1778
+ encoding = encoding || 'utf8';
1779
+ }
1780
+
1781
+ if (isBuffer) {
1782
+ encoding = null;
1783
+ }
1784
+
1785
+ const stream = new PassThroughStream({objectMode});
1786
+
1787
+ if (encoding) {
1788
+ stream.setEncoding(encoding);
1789
+ }
1790
+
1791
+ let length = 0;
1792
+ const chunks = [];
1793
+
1794
+ stream.on('data', chunk => {
1795
+ chunks.push(chunk);
1796
+
1797
+ if (objectMode) {
1798
+ length = chunks.length;
1799
+ } else {
1800
+ length += chunk.length;
1801
+ }
1802
+ });
1803
+
1804
+ stream.getBufferedValue = () => {
1805
+ if (array) {
1806
+ return chunks;
1807
+ }
1808
+
1809
+ return isBuffer ? Buffer.concat(chunks, length) : chunks.join('');
1810
+ };
1811
+
1812
+ stream.getBufferedLength = () => length;
1813
+
1814
+ return stream;
1815
+ };
1816
+
1817
+ const {constants: BufferConstants} = require$$0$4;
1818
+ const stream$1 = require$$0$3;
1819
+ const {promisify} = require$$0;
1820
+ const bufferStream = bufferStream$1;
1821
+
1822
+ const streamPipelinePromisified = promisify(stream$1.pipeline);
1823
+
1824
+ class MaxBufferError extends Error {
1825
+ constructor() {
1826
+ super('maxBuffer exceeded');
1827
+ this.name = 'MaxBufferError';
1828
+ }
1829
+ }
1830
+
1831
+ async function getStream$1(inputStream, options) {
1832
+ if (!inputStream) {
1833
+ throw new Error('Expected a stream');
1834
+ }
1835
+
1836
+ options = {
1837
+ maxBuffer: Infinity,
1838
+ ...options
1839
+ };
1840
+
1841
+ const {maxBuffer} = options;
1842
+ const stream = bufferStream(options);
1843
+
1844
+ await new Promise((resolve, reject) => {
1845
+ const rejectPromise = error => {
1846
+ // Don't retrieve an oversized buffer.
1847
+ if (error && stream.getBufferedLength() <= BufferConstants.MAX_LENGTH) {
1848
+ error.bufferedData = stream.getBufferedValue();
1849
+ }
1850
+
1851
+ reject(error);
1852
+ };
1853
+
1854
+ (async () => {
1855
+ try {
1856
+ await streamPipelinePromisified(inputStream, stream);
1857
+ resolve();
1858
+ } catch (error) {
1859
+ rejectPromise(error);
1860
+ }
1861
+ })();
1862
+
1863
+ stream.on('data', () => {
1864
+ if (stream.getBufferedLength() > maxBuffer) {
1865
+ rejectPromise(new MaxBufferError());
1866
+ }
1867
+ });
1868
+ });
1869
+
1870
+ return stream.getBufferedValue();
1871
+ }
1872
+
1873
+ getStream$2.exports = getStream$1;
1874
+ getStream$2.exports.buffer = (stream, options) => getStream$1(stream, {...options, encoding: 'buffer'});
1875
+ getStream$2.exports.array = (stream, options) => getStream$1(stream, {...options, array: true});
1876
+ getStream$2.exports.MaxBufferError = MaxBufferError;
1877
+
1878
+ const { PassThrough } = require$$0$3;
1879
+
1880
+ var mergeStream$1 = function (/*streams...*/) {
1881
+ var sources = [];
1882
+ var output = new PassThrough({objectMode: true});
1883
+
1884
+ output.setMaxListeners(0);
1885
+
1886
+ output.add = add;
1887
+ output.isEmpty = isEmpty;
1888
+
1889
+ output.on('unpipe', remove);
1890
+
1891
+ Array.prototype.slice.call(arguments).forEach(add);
1892
+
1893
+ return output
1894
+
1895
+ function add (source) {
1896
+ if (Array.isArray(source)) {
1897
+ source.forEach(add);
1898
+ return this
1899
+ }
1900
+
1901
+ sources.push(source);
1902
+ source.once('end', remove.bind(null, source));
1903
+ source.once('error', output.emit.bind(output, 'error'));
1904
+ source.pipe(output, {end: false});
1905
+ return this
1906
+ }
1907
+
1908
+ function isEmpty () {
1909
+ return sources.length == 0;
1910
+ }
1911
+
1912
+ function remove (source) {
1913
+ sources = sources.filter(function (it) { return it !== source });
1914
+ if (!sources.length && output.readable) { output.end(); }
1915
+ }
1916
+ };
1917
+
1918
+ const isStream = isStream_1;
1919
+ const getStream = getStream$2.exports;
1920
+ const mergeStream = mergeStream$1;
1921
+
1922
+ // `input` option
1923
+ const handleInput$1 = (spawned, input) => {
1924
+ // Checking for stdin is workaround for https://github.com/nodejs/node/issues/26852
1925
+ // @todo remove `|| spawned.stdin === undefined` once we drop support for Node.js <=12.2.0
1926
+ if (input === undefined || spawned.stdin === undefined) {
1927
+ return;
1928
+ }
1929
+
1930
+ if (isStream(input)) {
1931
+ input.pipe(spawned.stdin);
1932
+ } else {
1933
+ spawned.stdin.end(input);
1934
+ }
1935
+ };
1936
+
1937
+ // `all` interleaves `stdout` and `stderr`
1938
+ const makeAllStream$1 = (spawned, {all}) => {
1939
+ if (!all || (!spawned.stdout && !spawned.stderr)) {
1940
+ return;
1941
+ }
1942
+
1943
+ const mixed = mergeStream();
1944
+
1945
+ if (spawned.stdout) {
1946
+ mixed.add(spawned.stdout);
1947
+ }
1948
+
1949
+ if (spawned.stderr) {
1950
+ mixed.add(spawned.stderr);
1951
+ }
1952
+
1953
+ return mixed;
1954
+ };
1955
+
1956
+ // On failure, `result.stdout|stderr|all` should contain the currently buffered stream
1957
+ const getBufferedData = async (stream, streamPromise) => {
1958
+ if (!stream) {
1959
+ return;
1960
+ }
1961
+
1962
+ stream.destroy();
1963
+
1964
+ try {
1965
+ return await streamPromise;
1966
+ } catch (error) {
1967
+ return error.bufferedData;
1968
+ }
1969
+ };
1970
+
1971
+ const getStreamPromise = (stream, {encoding, buffer, maxBuffer}) => {
1972
+ if (!stream || !buffer) {
1973
+ return;
1974
+ }
1975
+
1976
+ if (encoding) {
1977
+ return getStream(stream, {encoding, maxBuffer});
1978
+ }
1979
+
1980
+ return getStream.buffer(stream, {maxBuffer});
1981
+ };
1982
+
1983
+ // Retrieve result of child process: exit code, signal, error, streams (stdout/stderr/all)
1984
+ const getSpawnedResult$1 = async ({stdout, stderr, all}, {encoding, buffer, maxBuffer}, processDone) => {
1985
+ const stdoutPromise = getStreamPromise(stdout, {encoding, buffer, maxBuffer});
1986
+ const stderrPromise = getStreamPromise(stderr, {encoding, buffer, maxBuffer});
1987
+ const allPromise = getStreamPromise(all, {encoding, buffer, maxBuffer: maxBuffer * 2});
1988
+
1989
+ try {
1990
+ return await Promise.all([processDone, stdoutPromise, stderrPromise, allPromise]);
1991
+ } catch (error) {
1992
+ return Promise.all([
1993
+ {error, signal: error.signal, timedOut: error.timedOut},
1994
+ getBufferedData(stdout, stdoutPromise),
1995
+ getBufferedData(stderr, stderrPromise),
1996
+ getBufferedData(all, allPromise)
1997
+ ]);
1998
+ }
1999
+ };
2000
+
2001
+ const validateInputSync$1 = ({input}) => {
2002
+ if (isStream(input)) {
2003
+ throw new TypeError('The `input` option cannot be a stream in sync mode');
2004
+ }
2005
+ };
2006
+
2007
+ var stream = {
2008
+ handleInput: handleInput$1,
2009
+ makeAllStream: makeAllStream$1,
2010
+ getSpawnedResult: getSpawnedResult$1,
2011
+ validateInputSync: validateInputSync$1
2012
+ };
2013
+
2014
+ const nativePromisePrototype = (async () => {})().constructor.prototype;
2015
+ const descriptors = ['then', 'catch', 'finally'].map(property => [
2016
+ property,
2017
+ Reflect.getOwnPropertyDescriptor(nativePromisePrototype, property)
2018
+ ]);
2019
+
2020
+ // The return value is a mixin of `childProcess` and `Promise`
2021
+ const mergePromise$1 = (spawned, promise) => {
2022
+ for (const [property, descriptor] of descriptors) {
2023
+ // Starting the main `promise` is deferred to avoid consuming streams
2024
+ const value = typeof promise === 'function' ?
2025
+ (...args) => Reflect.apply(descriptor.value, promise(), args) :
2026
+ descriptor.value.bind(promise);
2027
+
2028
+ Reflect.defineProperty(spawned, property, {...descriptor, value});
2029
+ }
2030
+
2031
+ return spawned;
2032
+ };
2033
+
2034
+ // Use promises instead of `child_process` events
2035
+ const getSpawnedPromise$1 = spawned => {
2036
+ return new Promise((resolve, reject) => {
2037
+ spawned.on('exit', (exitCode, signal) => {
2038
+ resolve({exitCode, signal});
2039
+ });
2040
+
2041
+ spawned.on('error', error => {
2042
+ reject(error);
2043
+ });
2044
+
2045
+ if (spawned.stdin) {
2046
+ spawned.stdin.on('error', error => {
2047
+ reject(error);
2048
+ });
2049
+ }
2050
+ });
2051
+ };
2052
+
2053
+ var promise = {
2054
+ mergePromise: mergePromise$1,
2055
+ getSpawnedPromise: getSpawnedPromise$1
2056
+ };
2057
+
2058
+ const normalizeArgs = (file, args = []) => {
2059
+ if (!Array.isArray(args)) {
2060
+ return [file];
2061
+ }
2062
+
2063
+ return [file, ...args];
2064
+ };
2065
+
2066
+ const NO_ESCAPE_REGEXP = /^[\w.-]+$/;
2067
+ const DOUBLE_QUOTES_REGEXP = /"/g;
2068
+
2069
+ const escapeArg = arg => {
2070
+ if (typeof arg !== 'string' || NO_ESCAPE_REGEXP.test(arg)) {
2071
+ return arg;
2072
+ }
2073
+
2074
+ return `"${arg.replace(DOUBLE_QUOTES_REGEXP, '\\"')}"`;
2075
+ };
2076
+
2077
+ const joinCommand$1 = (file, args) => {
2078
+ return normalizeArgs(file, args).join(' ');
2079
+ };
2080
+
2081
+ const getEscapedCommand$1 = (file, args) => {
2082
+ return normalizeArgs(file, args).map(arg => escapeArg(arg)).join(' ');
2083
+ };
2084
+
2085
+ const SPACES_REGEXP = / +/g;
2086
+
2087
+ // Handle `execa.command()`
2088
+ const parseCommand$1 = command => {
2089
+ const tokens = [];
2090
+ for (const token of command.trim().split(SPACES_REGEXP)) {
2091
+ // Allow spaces to be escaped by a backslash if not meant as a delimiter
2092
+ const previousToken = tokens[tokens.length - 1];
2093
+ if (previousToken && previousToken.endsWith('\\')) {
2094
+ // Merge previous token with current one
2095
+ tokens[tokens.length - 1] = `${previousToken.slice(0, -1)} ${token}`;
2096
+ } else {
2097
+ tokens.push(token);
2098
+ }
2099
+ }
2100
+
2101
+ return tokens;
2102
+ };
2103
+
2104
+ var command = {
2105
+ joinCommand: joinCommand$1,
2106
+ getEscapedCommand: getEscapedCommand$1,
2107
+ parseCommand: parseCommand$1
2108
+ };
2109
+
2110
+ const path = path$5;
2111
+ const childProcess = require$$0$1;
2112
+ const crossSpawn = crossSpawn$1.exports;
2113
+ const stripFinalNewline = stripFinalNewline$1;
2114
+ const npmRunPath = npmRunPath$1.exports;
2115
+ const onetime = onetime$1.exports;
2116
+ const makeError = error;
2117
+ const normalizeStdio = stdio.exports;
2118
+ const {spawnedKill, spawnedCancel, setupTimeout, validateTimeout, setExitHandler} = kill;
2119
+ const {handleInput, getSpawnedResult, makeAllStream, validateInputSync} = stream;
2120
+ const {mergePromise, getSpawnedPromise} = promise;
2121
+ const {joinCommand, parseCommand, getEscapedCommand} = command;
2122
+
2123
+ const DEFAULT_MAX_BUFFER = 1000 * 1000 * 100;
2124
+
2125
+ const getEnv = ({env: envOption, extendEnv, preferLocal, localDir, execPath}) => {
2126
+ const env = extendEnv ? {...process.env, ...envOption} : envOption;
2127
+
2128
+ if (preferLocal) {
2129
+ return npmRunPath.env({env, cwd: localDir, execPath});
2130
+ }
2131
+
2132
+ return env;
2133
+ };
2134
+
2135
+ const handleArguments = (file, args, options = {}) => {
2136
+ const parsed = crossSpawn._parse(file, args, options);
2137
+ file = parsed.command;
2138
+ args = parsed.args;
2139
+ options = parsed.options;
2140
+
2141
+ options = {
2142
+ maxBuffer: DEFAULT_MAX_BUFFER,
2143
+ buffer: true,
2144
+ stripFinalNewline: true,
2145
+ extendEnv: true,
2146
+ preferLocal: false,
2147
+ localDir: options.cwd || process.cwd(),
2148
+ execPath: process.execPath,
2149
+ encoding: 'utf8',
2150
+ reject: true,
2151
+ cleanup: true,
2152
+ all: false,
2153
+ windowsHide: true,
2154
+ ...options
2155
+ };
2156
+
2157
+ options.env = getEnv(options);
2158
+
2159
+ options.stdio = normalizeStdio(options);
2160
+
2161
+ if (process.platform === 'win32' && path.basename(file, '.exe') === 'cmd') {
2162
+ // #116
2163
+ args.unshift('/q');
2164
+ }
2165
+
2166
+ return {file, args, options, parsed};
2167
+ };
2168
+
2169
+ const handleOutput = (options, value, error) => {
2170
+ if (typeof value !== 'string' && !Buffer.isBuffer(value)) {
2171
+ // When `execa.sync()` errors, we normalize it to '' to mimic `execa()`
2172
+ return error === undefined ? undefined : '';
2173
+ }
2174
+
2175
+ if (options.stripFinalNewline) {
2176
+ return stripFinalNewline(value);
2177
+ }
2178
+
2179
+ return value;
2180
+ };
2181
+
2182
+ const execa = (file, args, options) => {
2183
+ const parsed = handleArguments(file, args, options);
2184
+ const command = joinCommand(file, args);
2185
+ const escapedCommand = getEscapedCommand(file, args);
2186
+
2187
+ validateTimeout(parsed.options);
2188
+
2189
+ let spawned;
2190
+ try {
2191
+ spawned = childProcess.spawn(parsed.file, parsed.args, parsed.options);
2192
+ } catch (error) {
2193
+ // Ensure the returned error is always both a promise and a child process
2194
+ const dummySpawned = new childProcess.ChildProcess();
2195
+ const errorPromise = Promise.reject(makeError({
2196
+ error,
2197
+ stdout: '',
2198
+ stderr: '',
2199
+ all: '',
2200
+ command,
2201
+ escapedCommand,
2202
+ parsed,
2203
+ timedOut: false,
2204
+ isCanceled: false,
2205
+ killed: false
2206
+ }));
2207
+ return mergePromise(dummySpawned, errorPromise);
2208
+ }
2209
+
2210
+ const spawnedPromise = getSpawnedPromise(spawned);
2211
+ const timedPromise = setupTimeout(spawned, parsed.options, spawnedPromise);
2212
+ const processDone = setExitHandler(spawned, parsed.options, timedPromise);
2213
+
2214
+ const context = {isCanceled: false};
2215
+
2216
+ spawned.kill = spawnedKill.bind(null, spawned.kill.bind(spawned));
2217
+ spawned.cancel = spawnedCancel.bind(null, spawned, context);
2218
+
2219
+ const handlePromise = async () => {
2220
+ const [{error, exitCode, signal, timedOut}, stdoutResult, stderrResult, allResult] = await getSpawnedResult(spawned, parsed.options, processDone);
2221
+ const stdout = handleOutput(parsed.options, stdoutResult);
2222
+ const stderr = handleOutput(parsed.options, stderrResult);
2223
+ const all = handleOutput(parsed.options, allResult);
2224
+
2225
+ if (error || exitCode !== 0 || signal !== null) {
2226
+ const returnedError = makeError({
2227
+ error,
2228
+ exitCode,
2229
+ signal,
2230
+ stdout,
2231
+ stderr,
2232
+ all,
2233
+ command,
2234
+ escapedCommand,
2235
+ parsed,
2236
+ timedOut,
2237
+ isCanceled: context.isCanceled,
2238
+ killed: spawned.killed
2239
+ });
2240
+
2241
+ if (!parsed.options.reject) {
2242
+ return returnedError;
2243
+ }
2244
+
2245
+ throw returnedError;
2246
+ }
2247
+
2248
+ return {
2249
+ command,
2250
+ escapedCommand,
2251
+ exitCode: 0,
2252
+ stdout,
2253
+ stderr,
2254
+ all,
2255
+ failed: false,
2256
+ timedOut: false,
2257
+ isCanceled: false,
2258
+ killed: false
2259
+ };
2260
+ };
2261
+
2262
+ const handlePromiseOnce = onetime(handlePromise);
2263
+
2264
+ handleInput(spawned, parsed.options.input);
2265
+
2266
+ spawned.all = makeAllStream(spawned, parsed.options);
2267
+
2268
+ return mergePromise(spawned, handlePromiseOnce);
2269
+ };
2270
+
2271
+ execa$2.exports = execa;
2272
+
2273
+ execa$2.exports.sync = (file, args, options) => {
2274
+ const parsed = handleArguments(file, args, options);
2275
+ const command = joinCommand(file, args);
2276
+ const escapedCommand = getEscapedCommand(file, args);
2277
+
2278
+ validateInputSync(parsed.options);
2279
+
2280
+ let result;
2281
+ try {
2282
+ result = childProcess.spawnSync(parsed.file, parsed.args, parsed.options);
2283
+ } catch (error) {
2284
+ throw makeError({
2285
+ error,
2286
+ stdout: '',
2287
+ stderr: '',
2288
+ all: '',
2289
+ command,
2290
+ escapedCommand,
2291
+ parsed,
2292
+ timedOut: false,
2293
+ isCanceled: false,
2294
+ killed: false
2295
+ });
2296
+ }
2297
+
2298
+ const stdout = handleOutput(parsed.options, result.stdout, result.error);
2299
+ const stderr = handleOutput(parsed.options, result.stderr, result.error);
2300
+
2301
+ if (result.error || result.status !== 0 || result.signal !== null) {
2302
+ const error = makeError({
2303
+ stdout,
2304
+ stderr,
2305
+ error: result.error,
2306
+ signal: result.signal,
2307
+ exitCode: result.status,
2308
+ command,
2309
+ escapedCommand,
2310
+ parsed,
2311
+ timedOut: result.error && result.error.code === 'ETIMEDOUT',
2312
+ isCanceled: false,
2313
+ killed: result.signal !== null
2314
+ });
2315
+
2316
+ if (!parsed.options.reject) {
2317
+ return error;
2318
+ }
2319
+
2320
+ throw error;
2321
+ }
2322
+
2323
+ return {
2324
+ command,
2325
+ escapedCommand,
2326
+ exitCode: 0,
2327
+ stdout,
2328
+ stderr,
2329
+ failed: false,
2330
+ timedOut: false,
2331
+ isCanceled: false,
2332
+ killed: false
2333
+ };
2334
+ };
2335
+
2336
+ execa$2.exports.command = (command, options) => {
2337
+ const [file, ...args] = parseCommand(command);
2338
+ return execa(file, args, options);
2339
+ };
2340
+
2341
+ execa$2.exports.commandSync = (command, options) => {
2342
+ const [file, ...args] = parseCommand(command);
2343
+ return execa.sync(file, args, options);
2344
+ };
2345
+
2346
+ execa$2.exports.node = (scriptPath, args, options = {}) => {
2347
+ if (args && !Array.isArray(args) && typeof args === 'object') {
2348
+ options = args;
2349
+ args = [];
2350
+ }
2351
+
2352
+ const stdio = normalizeStdio.node(options);
2353
+ const defaultExecArgv = process.execArgv.filter(arg => !arg.startsWith('--inspect'));
2354
+
2355
+ const {
2356
+ nodePath = process.execPath,
2357
+ nodeOptions = defaultExecArgv
2358
+ } = options;
2359
+
2360
+ return execa(
2361
+ nodePath,
2362
+ [
2363
+ ...nodeOptions,
2364
+ scriptPath,
2365
+ ...(Array.isArray(args) ? args : [])
2366
+ ],
2367
+ {
2368
+ ...options,
2369
+ stdin: undefined,
2370
+ stdout: undefined,
2371
+ stderr: undefined,
2372
+ stdio,
2373
+ shell: false
2374
+ }
2375
+ );
2376
+ };
2377
+
2378
+ var execa$1 = execa$2.exports;
2379
+
2380
+ // src/detect.ts
2381
+ var LOCKS = {
2382
+ "pnpm-lock.yaml": "pnpm",
2383
+ "yarn.lock": "yarn",
2384
+ "package-lock.json": "npm"
2385
+ };
2386
+ async function detectPackageManager(cwd = process.cwd()) {
2387
+ const result = await findUp(Object.keys(LOCKS), { cwd });
2388
+ const agent = result ? LOCKS[path$5.basename(result)] : null;
2389
+ return agent;
2390
+ }
2391
+ async function installPackage(names, options = {}) {
2392
+ const agent = options.packageManager || await detectPackageManager(options.cwd) || "npm";
2393
+ if (!Array.isArray(names))
2394
+ names = [names];
2395
+ const args = options.additionalArgs || [];
2396
+ if (options.preferOffline)
2397
+ args.unshift("--prefer-offline");
2398
+ return execa$1(agent, [
2399
+ agent === "yarn" ? "add" : "install",
2400
+ options.dev ? "-D" : "",
2401
+ ...args,
2402
+ ...names
2403
+ ].filter(Boolean), {
2404
+ stdio: options.silent ? "ignore" : "inherit",
2405
+ cwd: options.cwd
2406
+ });
2407
+ }
2408
+
2409
+ export { detectPackageManager, installPackage };