vitest 0.0.129 → 0.0.133

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.
Files changed (40) hide show
  1. package/dist/_commonjsHelpers-c9e3b764.js +1 -0
  2. package/dist/cli.js +10 -9
  3. package/dist/constants-0211a379.js +34 -0
  4. package/dist/diff-18d4a7eb.js +4750 -0
  5. package/dist/entry.js +94 -33
  6. package/dist/externalize-2f63779d.js +1 -0
  7. package/dist/global-5d1fb309.js +21 -0
  8. package/dist/index-26cb6e63.js +1644 -0
  9. package/dist/index-354a6abd.js +40 -0
  10. package/dist/index-4cd25949.js +782 -0
  11. package/dist/index-720a83c6.js +396 -0
  12. package/dist/index-7975be53.js +331 -0
  13. package/dist/index-7f7acd60.js +8548 -0
  14. package/dist/index-e909c175.js +63 -0
  15. package/dist/index-fa899e66.js +5708 -0
  16. package/dist/index.d.ts +142 -27
  17. package/dist/index.js +4 -3
  18. package/dist/jest-mock-30625866.js +1 -0
  19. package/dist/magic-string.es-94000aea.js +1361 -0
  20. package/dist/node.d.ts +111 -4
  21. package/dist/node.js +9 -8
  22. package/dist/rpc-8c7cc374.js +1 -0
  23. package/dist/setup-5aaf533e.js +4365 -0
  24. package/dist/vi-aec007e7.js +3461 -0
  25. package/dist/worker.js +11 -7
  26. package/package.json +9 -9
  27. package/dist/constants-868b9a2e.js +0 -33
  28. package/dist/diff-be830986.js +0 -4751
  29. package/dist/global-0254dd68.js +0 -20
  30. package/dist/index-06712022.js +0 -39
  31. package/dist/index-42a3a132.js +0 -366
  32. package/dist/index-42d44ee5.js +0 -1643
  33. package/dist/index-93dcb598.js +0 -5707
  34. package/dist/index-a73f33e0.js +0 -62
  35. package/dist/index-cb02ee01.js +0 -330
  36. package/dist/index-cce5de77.js +0 -781
  37. package/dist/index-d30b5ed0.js +0 -8579
  38. package/dist/magic-string.es-98a8bfa0.js +0 -1360
  39. package/dist/setup-6e09a65a.js +0 -4364
  40. package/dist/vi-fe26a646.js +0 -3460
@@ -1,1643 +0,0 @@
1
- import path$2 from 'path';
2
- import fs$2 from 'fs';
3
- import require$$0 from 'util';
4
- import childProcess$1 from 'child_process';
5
- import { p as pathKey, m as mergeStream$1, a as getStream$1, b as crossSpawn$1 } from './index-cce5de77.js';
6
- import { a as signalExit, b as onetime$1 } from './index-cb02ee01.js';
7
- import require$$0$1 from 'os';
8
- import './_commonjsHelpers-c9e3b764.js';
9
- import 'buffer';
10
- import 'stream';
11
- import 'assert';
12
- import 'events';
13
-
14
- var findUp$1 = {exports: {}};
15
-
16
- var locatePath = {exports: {}};
17
-
18
- class Node {
19
- /// value;
20
- /// next;
21
-
22
- constructor(value) {
23
- this.value = value;
24
-
25
- // TODO: Remove this when targeting Node.js 12.
26
- this.next = undefined;
27
- }
28
- }
29
-
30
- class Queue$1 {
31
- // TODO: Use private class fields when targeting Node.js 12.
32
- // #_head;
33
- // #_tail;
34
- // #_size;
35
-
36
- constructor() {
37
- this.clear();
38
- }
39
-
40
- enqueue(value) {
41
- const node = new Node(value);
42
-
43
- if (this._head) {
44
- this._tail.next = node;
45
- this._tail = node;
46
- } else {
47
- this._head = node;
48
- this._tail = node;
49
- }
50
-
51
- this._size++;
52
- }
53
-
54
- dequeue() {
55
- const current = this._head;
56
- if (!current) {
57
- return;
58
- }
59
-
60
- this._head = this._head.next;
61
- this._size--;
62
- return current.value;
63
- }
64
-
65
- clear() {
66
- this._head = undefined;
67
- this._tail = undefined;
68
- this._size = 0;
69
- }
70
-
71
- get size() {
72
- return this._size;
73
- }
74
-
75
- * [Symbol.iterator]() {
76
- let current = this._head;
77
-
78
- while (current) {
79
- yield current.value;
80
- current = current.next;
81
- }
82
- }
83
- }
84
-
85
- var yoctoQueue = Queue$1;
86
-
87
- const Queue = yoctoQueue;
88
-
89
- const pLimit$1 = concurrency => {
90
- if (!((Number.isInteger(concurrency) || concurrency === Infinity) && concurrency > 0)) {
91
- throw new TypeError('Expected `concurrency` to be a number from 1 and up');
92
- }
93
-
94
- const queue = new Queue();
95
- let activeCount = 0;
96
-
97
- const next = () => {
98
- activeCount--;
99
-
100
- if (queue.size > 0) {
101
- queue.dequeue()();
102
- }
103
- };
104
-
105
- const run = async (fn, resolve, ...args) => {
106
- activeCount++;
107
-
108
- const result = (async () => fn(...args))();
109
-
110
- resolve(result);
111
-
112
- try {
113
- await result;
114
- } catch {}
115
-
116
- next();
117
- };
118
-
119
- const enqueue = (fn, resolve, ...args) => {
120
- queue.enqueue(run.bind(null, fn, resolve, ...args));
121
-
122
- (async () => {
123
- // This function needs to wait until the next microtask before comparing
124
- // `activeCount` to `concurrency`, because `activeCount` is updated asynchronously
125
- // when the run function is dequeued and called. The comparison in the if-statement
126
- // needs to happen asynchronously as well to get an up-to-date value for `activeCount`.
127
- await Promise.resolve();
128
-
129
- if (activeCount < concurrency && queue.size > 0) {
130
- queue.dequeue()();
131
- }
132
- })();
133
- };
134
-
135
- const generator = (fn, ...args) => new Promise(resolve => {
136
- enqueue(fn, resolve, ...args);
137
- });
138
-
139
- Object.defineProperties(generator, {
140
- activeCount: {
141
- get: () => activeCount
142
- },
143
- pendingCount: {
144
- get: () => queue.size
145
- },
146
- clearQueue: {
147
- value: () => {
148
- queue.clear();
149
- }
150
- }
151
- });
152
-
153
- return generator;
154
- };
155
-
156
- var pLimit_1 = pLimit$1;
157
-
158
- const pLimit = pLimit_1;
159
-
160
- class EndError extends Error {
161
- constructor(value) {
162
- super();
163
- this.value = value;
164
- }
165
- }
166
-
167
- // The input can also be a promise, so we await it
168
- const testElement = async (element, tester) => tester(await element);
169
-
170
- // The input can also be a promise, so we `Promise.all()` them both
171
- const finder = async element => {
172
- const values = await Promise.all(element);
173
- if (values[1] === true) {
174
- throw new EndError(values[0]);
175
- }
176
-
177
- return false;
178
- };
179
-
180
- const pLocate$1 = async (iterable, tester, options) => {
181
- options = {
182
- concurrency: Infinity,
183
- preserveOrder: true,
184
- ...options
185
- };
186
-
187
- const limit = pLimit(options.concurrency);
188
-
189
- // Start all the promises concurrently with optional limit
190
- const items = [...iterable].map(element => [element, limit(testElement, element, tester)]);
191
-
192
- // Check the promises either serially or concurrently
193
- const checkLimit = pLimit(options.preserveOrder ? 1 : Infinity);
194
-
195
- try {
196
- await Promise.all(items.map(element => checkLimit(finder, element)));
197
- } catch (error) {
198
- if (error instanceof EndError) {
199
- return error.value;
200
- }
201
-
202
- throw error;
203
- }
204
- };
205
-
206
- var pLocate_1 = pLocate$1;
207
-
208
- const path$1 = path$2;
209
- const fs$1 = fs$2;
210
- const {promisify: promisify$1} = require$$0;
211
- const pLocate = pLocate_1;
212
-
213
- const fsStat = promisify$1(fs$1.stat);
214
- const fsLStat = promisify$1(fs$1.lstat);
215
-
216
- const typeMappings = {
217
- directory: 'isDirectory',
218
- file: 'isFile'
219
- };
220
-
221
- function checkType({type}) {
222
- if (type in typeMappings) {
223
- return;
224
- }
225
-
226
- throw new Error(`Invalid type specified: ${type}`);
227
- }
228
-
229
- const matchType = (type, stat) => type === undefined || stat[typeMappings[type]]();
230
-
231
- locatePath.exports = async (paths, options) => {
232
- options = {
233
- cwd: process.cwd(),
234
- type: 'file',
235
- allowSymlinks: true,
236
- ...options
237
- };
238
-
239
- checkType(options);
240
-
241
- const statFn = options.allowSymlinks ? fsStat : fsLStat;
242
-
243
- return pLocate(paths, async path_ => {
244
- try {
245
- const stat = await statFn(path$1.resolve(options.cwd, path_));
246
- return matchType(options.type, stat);
247
- } catch {
248
- return false;
249
- }
250
- }, options);
251
- };
252
-
253
- locatePath.exports.sync = (paths, options) => {
254
- options = {
255
- cwd: process.cwd(),
256
- allowSymlinks: true,
257
- type: 'file',
258
- ...options
259
- };
260
-
261
- checkType(options);
262
-
263
- const statFn = options.allowSymlinks ? fs$1.statSync : fs$1.lstatSync;
264
-
265
- for (const path_ of paths) {
266
- try {
267
- const stat = statFn(path$1.resolve(options.cwd, path_));
268
-
269
- if (matchType(options.type, stat)) {
270
- return path_;
271
- }
272
- } catch {}
273
- }
274
- };
275
-
276
- var pathExists = {exports: {}};
277
-
278
- const fs = fs$2;
279
- const {promisify} = require$$0;
280
-
281
- const pAccess = promisify(fs.access);
282
-
283
- pathExists.exports = async path => {
284
- try {
285
- await pAccess(path);
286
- return true;
287
- } catch (_) {
288
- return false;
289
- }
290
- };
291
-
292
- pathExists.exports.sync = path => {
293
- try {
294
- fs.accessSync(path);
295
- return true;
296
- } catch (_) {
297
- return false;
298
- }
299
- };
300
-
301
- (function (module) {
302
- const path = path$2;
303
- const locatePath$1 = locatePath.exports;
304
- const pathExists$1 = pathExists.exports;
305
-
306
- const stop = Symbol('findUp.stop');
307
-
308
- module.exports = async (name, options = {}) => {
309
- let directory = path.resolve(options.cwd || '');
310
- const {root} = path.parse(directory);
311
- const paths = [].concat(name);
312
-
313
- const runMatcher = async locateOptions => {
314
- if (typeof name !== 'function') {
315
- return locatePath$1(paths, locateOptions);
316
- }
317
-
318
- const foundPath = await name(locateOptions.cwd);
319
- if (typeof foundPath === 'string') {
320
- return locatePath$1([foundPath], locateOptions);
321
- }
322
-
323
- return foundPath;
324
- };
325
-
326
- // eslint-disable-next-line no-constant-condition
327
- while (true) {
328
- // eslint-disable-next-line no-await-in-loop
329
- const foundPath = await runMatcher({...options, cwd: directory});
330
-
331
- if (foundPath === stop) {
332
- return;
333
- }
334
-
335
- if (foundPath) {
336
- return path.resolve(directory, foundPath);
337
- }
338
-
339
- if (directory === root) {
340
- return;
341
- }
342
-
343
- directory = path.dirname(directory);
344
- }
345
- };
346
-
347
- module.exports.sync = (name, options = {}) => {
348
- let directory = path.resolve(options.cwd || '');
349
- const {root} = path.parse(directory);
350
- const paths = [].concat(name);
351
-
352
- const runMatcher = locateOptions => {
353
- if (typeof name !== 'function') {
354
- return locatePath$1.sync(paths, locateOptions);
355
- }
356
-
357
- const foundPath = name(locateOptions.cwd);
358
- if (typeof foundPath === 'string') {
359
- return locatePath$1.sync([foundPath], locateOptions);
360
- }
361
-
362
- return foundPath;
363
- };
364
-
365
- // eslint-disable-next-line no-constant-condition
366
- while (true) {
367
- const foundPath = runMatcher({...options, cwd: directory});
368
-
369
- if (foundPath === stop) {
370
- return;
371
- }
372
-
373
- if (foundPath) {
374
- return path.resolve(directory, foundPath);
375
- }
376
-
377
- if (directory === root) {
378
- return;
379
- }
380
-
381
- directory = path.dirname(directory);
382
- }
383
- };
384
-
385
- module.exports.exists = pathExists$1;
386
-
387
- module.exports.sync.exists = pathExists$1.sync;
388
-
389
- module.exports.stop = stop;
390
- }(findUp$1));
391
-
392
- var findUp = findUp$1.exports;
393
-
394
- var execa$2 = {exports: {}};
395
-
396
- var stripFinalNewline$1 = input => {
397
- const LF = typeof input === 'string' ? '\n' : '\n'.charCodeAt();
398
- const CR = typeof input === 'string' ? '\r' : '\r'.charCodeAt();
399
-
400
- if (input[input.length - 1] === LF) {
401
- input = input.slice(0, input.length - 1);
402
- }
403
-
404
- if (input[input.length - 1] === CR) {
405
- input = input.slice(0, input.length - 1);
406
- }
407
-
408
- return input;
409
- };
410
-
411
- var npmRunPath$1 = {exports: {}};
412
-
413
- (function (module) {
414
- const path = path$2;
415
- const pathKey$1 = pathKey.exports;
416
-
417
- const npmRunPath = options => {
418
- options = {
419
- cwd: process.cwd(),
420
- path: process.env[pathKey$1()],
421
- execPath: process.execPath,
422
- ...options
423
- };
424
-
425
- let previous;
426
- let cwdPath = path.resolve(options.cwd);
427
- const result = [];
428
-
429
- while (previous !== cwdPath) {
430
- result.push(path.join(cwdPath, 'node_modules/.bin'));
431
- previous = cwdPath;
432
- cwdPath = path.resolve(cwdPath, '..');
433
- }
434
-
435
- // Ensure the running `node` binary is used
436
- const execPathDir = path.resolve(options.cwd, options.execPath, '..');
437
- result.push(execPathDir);
438
-
439
- return result.concat(options.path).join(path.delimiter);
440
- };
441
-
442
- module.exports = npmRunPath;
443
- // TODO: Remove this for the next major release
444
- module.exports.default = npmRunPath;
445
-
446
- module.exports.env = options => {
447
- options = {
448
- env: process.env,
449
- ...options
450
- };
451
-
452
- const env = {...options.env};
453
- const path = pathKey$1({env});
454
-
455
- options.path = env[path];
456
- env[path] = module.exports(options);
457
-
458
- return env;
459
- };
460
- }(npmRunPath$1));
461
-
462
- var main = {};
463
-
464
- var signals = {};
465
-
466
- var core = {};
467
-
468
- Object.defineProperty(core,"__esModule",{value:true});core.SIGNALS=void 0;
469
-
470
- const SIGNALS=[
471
- {
472
- name:"SIGHUP",
473
- number:1,
474
- action:"terminate",
475
- description:"Terminal closed",
476
- standard:"posix"},
477
-
478
- {
479
- name:"SIGINT",
480
- number:2,
481
- action:"terminate",
482
- description:"User interruption with CTRL-C",
483
- standard:"ansi"},
484
-
485
- {
486
- name:"SIGQUIT",
487
- number:3,
488
- action:"core",
489
- description:"User interruption with CTRL-\\",
490
- standard:"posix"},
491
-
492
- {
493
- name:"SIGILL",
494
- number:4,
495
- action:"core",
496
- description:"Invalid machine instruction",
497
- standard:"ansi"},
498
-
499
- {
500
- name:"SIGTRAP",
501
- number:5,
502
- action:"core",
503
- description:"Debugger breakpoint",
504
- standard:"posix"},
505
-
506
- {
507
- name:"SIGABRT",
508
- number:6,
509
- action:"core",
510
- description:"Aborted",
511
- standard:"ansi"},
512
-
513
- {
514
- name:"SIGIOT",
515
- number:6,
516
- action:"core",
517
- description:"Aborted",
518
- standard:"bsd"},
519
-
520
- {
521
- name:"SIGBUS",
522
- number:7,
523
- action:"core",
524
- description:
525
- "Bus error due to misaligned, non-existing address or paging error",
526
- standard:"bsd"},
527
-
528
- {
529
- name:"SIGEMT",
530
- number:7,
531
- action:"terminate",
532
- description:"Command should be emulated but is not implemented",
533
- standard:"other"},
534
-
535
- {
536
- name:"SIGFPE",
537
- number:8,
538
- action:"core",
539
- description:"Floating point arithmetic error",
540
- standard:"ansi"},
541
-
542
- {
543
- name:"SIGKILL",
544
- number:9,
545
- action:"terminate",
546
- description:"Forced termination",
547
- standard:"posix",
548
- forced:true},
549
-
550
- {
551
- name:"SIGUSR1",
552
- number:10,
553
- action:"terminate",
554
- description:"Application-specific signal",
555
- standard:"posix"},
556
-
557
- {
558
- name:"SIGSEGV",
559
- number:11,
560
- action:"core",
561
- description:"Segmentation fault",
562
- standard:"ansi"},
563
-
564
- {
565
- name:"SIGUSR2",
566
- number:12,
567
- action:"terminate",
568
- description:"Application-specific signal",
569
- standard:"posix"},
570
-
571
- {
572
- name:"SIGPIPE",
573
- number:13,
574
- action:"terminate",
575
- description:"Broken pipe or socket",
576
- standard:"posix"},
577
-
578
- {
579
- name:"SIGALRM",
580
- number:14,
581
- action:"terminate",
582
- description:"Timeout or timer",
583
- standard:"posix"},
584
-
585
- {
586
- name:"SIGTERM",
587
- number:15,
588
- action:"terminate",
589
- description:"Termination",
590
- standard:"ansi"},
591
-
592
- {
593
- name:"SIGSTKFLT",
594
- number:16,
595
- action:"terminate",
596
- description:"Stack is empty or overflowed",
597
- standard:"other"},
598
-
599
- {
600
- name:"SIGCHLD",
601
- number:17,
602
- action:"ignore",
603
- description:"Child process terminated, paused or unpaused",
604
- standard:"posix"},
605
-
606
- {
607
- name:"SIGCLD",
608
- number:17,
609
- action:"ignore",
610
- description:"Child process terminated, paused or unpaused",
611
- standard:"other"},
612
-
613
- {
614
- name:"SIGCONT",
615
- number:18,
616
- action:"unpause",
617
- description:"Unpaused",
618
- standard:"posix",
619
- forced:true},
620
-
621
- {
622
- name:"SIGSTOP",
623
- number:19,
624
- action:"pause",
625
- description:"Paused",
626
- standard:"posix",
627
- forced:true},
628
-
629
- {
630
- name:"SIGTSTP",
631
- number:20,
632
- action:"pause",
633
- description:"Paused using CTRL-Z or \"suspend\"",
634
- standard:"posix"},
635
-
636
- {
637
- name:"SIGTTIN",
638
- number:21,
639
- action:"pause",
640
- description:"Background process cannot read terminal input",
641
- standard:"posix"},
642
-
643
- {
644
- name:"SIGBREAK",
645
- number:21,
646
- action:"terminate",
647
- description:"User interruption with CTRL-BREAK",
648
- standard:"other"},
649
-
650
- {
651
- name:"SIGTTOU",
652
- number:22,
653
- action:"pause",
654
- description:"Background process cannot write to terminal output",
655
- standard:"posix"},
656
-
657
- {
658
- name:"SIGURG",
659
- number:23,
660
- action:"ignore",
661
- description:"Socket received out-of-band data",
662
- standard:"bsd"},
663
-
664
- {
665
- name:"SIGXCPU",
666
- number:24,
667
- action:"core",
668
- description:"Process timed out",
669
- standard:"bsd"},
670
-
671
- {
672
- name:"SIGXFSZ",
673
- number:25,
674
- action:"core",
675
- description:"File too big",
676
- standard:"bsd"},
677
-
678
- {
679
- name:"SIGVTALRM",
680
- number:26,
681
- action:"terminate",
682
- description:"Timeout or timer",
683
- standard:"bsd"},
684
-
685
- {
686
- name:"SIGPROF",
687
- number:27,
688
- action:"terminate",
689
- description:"Timeout or timer",
690
- standard:"bsd"},
691
-
692
- {
693
- name:"SIGWINCH",
694
- number:28,
695
- action:"ignore",
696
- description:"Terminal window size changed",
697
- standard:"bsd"},
698
-
699
- {
700
- name:"SIGIO",
701
- number:29,
702
- action:"terminate",
703
- description:"I/O is available",
704
- standard:"other"},
705
-
706
- {
707
- name:"SIGPOLL",
708
- number:29,
709
- action:"terminate",
710
- description:"Watched event",
711
- standard:"other"},
712
-
713
- {
714
- name:"SIGINFO",
715
- number:29,
716
- action:"ignore",
717
- description:"Request for process information",
718
- standard:"other"},
719
-
720
- {
721
- name:"SIGPWR",
722
- number:30,
723
- action:"terminate",
724
- description:"Device running out of power",
725
- standard:"systemv"},
726
-
727
- {
728
- name:"SIGSYS",
729
- number:31,
730
- action:"core",
731
- description:"Invalid system call",
732
- standard:"other"},
733
-
734
- {
735
- name:"SIGUNUSED",
736
- number:31,
737
- action:"terminate",
738
- description:"Invalid system call",
739
- standard:"other"}];core.SIGNALS=SIGNALS;
740
-
741
- var realtime = {};
742
-
743
- Object.defineProperty(realtime,"__esModule",{value:true});realtime.SIGRTMAX=realtime.getRealtimeSignals=void 0;
744
- const getRealtimeSignals=function(){
745
- const length=SIGRTMAX-SIGRTMIN+1;
746
- return Array.from({length},getRealtimeSignal);
747
- };realtime.getRealtimeSignals=getRealtimeSignals;
748
-
749
- const getRealtimeSignal=function(value,index){
750
- return {
751
- name:`SIGRT${index+1}`,
752
- number:SIGRTMIN+index,
753
- action:"terminate",
754
- description:"Application-specific signal (realtime)",
755
- standard:"posix"};
756
-
757
- };
758
-
759
- const SIGRTMIN=34;
760
- const SIGRTMAX=64;realtime.SIGRTMAX=SIGRTMAX;
761
-
762
- Object.defineProperty(signals,"__esModule",{value:true});signals.getSignals=void 0;var _os$1=require$$0$1;
763
-
764
- var _core=core;
765
- var _realtime$1=realtime;
766
-
767
-
768
-
769
- const getSignals=function(){
770
- const realtimeSignals=(0, _realtime$1.getRealtimeSignals)();
771
- const signals=[..._core.SIGNALS,...realtimeSignals].map(normalizeSignal);
772
- return signals;
773
- };signals.getSignals=getSignals;
774
-
775
-
776
-
777
-
778
-
779
-
780
-
781
- const normalizeSignal=function({
782
- name,
783
- number:defaultNumber,
784
- description,
785
- action,
786
- forced=false,
787
- standard})
788
- {
789
- const{
790
- signals:{[name]:constantSignal}}=
791
- _os$1.constants;
792
- const supported=constantSignal!==undefined;
793
- const number=supported?constantSignal:defaultNumber;
794
- return {name,number,description,supported,action,forced,standard};
795
- };
796
-
797
- Object.defineProperty(main,"__esModule",{value:true});main.signalsByNumber=main.signalsByName=void 0;var _os=require$$0$1;
798
-
799
- var _signals=signals;
800
- var _realtime=realtime;
801
-
802
-
803
-
804
- const getSignalsByName=function(){
805
- const signals=(0, _signals.getSignals)();
806
- return signals.reduce(getSignalByName,{});
807
- };
808
-
809
- const getSignalByName=function(
810
- signalByNameMemo,
811
- {name,number,description,supported,action,forced,standard})
812
- {
813
- return {
814
- ...signalByNameMemo,
815
- [name]:{name,number,description,supported,action,forced,standard}};
816
-
817
- };
818
-
819
- const signalsByName$1=getSignalsByName();main.signalsByName=signalsByName$1;
820
-
821
-
822
-
823
-
824
- const getSignalsByNumber=function(){
825
- const signals=(0, _signals.getSignals)();
826
- const length=_realtime.SIGRTMAX+1;
827
- const signalsA=Array.from({length},(value,number)=>
828
- getSignalByNumber(number,signals));
829
-
830
- return Object.assign({},...signalsA);
831
- };
832
-
833
- const getSignalByNumber=function(number,signals){
834
- const signal=findSignalByNumber(number,signals);
835
-
836
- if(signal===undefined){
837
- return {};
838
- }
839
-
840
- const{name,description,supported,action,forced,standard}=signal;
841
- return {
842
- [number]:{
843
- name,
844
- number,
845
- description,
846
- supported,
847
- action,
848
- forced,
849
- standard}};
850
-
851
-
852
- };
853
-
854
-
855
-
856
- const findSignalByNumber=function(number,signals){
857
- const signal=signals.find(({name})=>_os.constants.signals[name]===number);
858
-
859
- if(signal!==undefined){
860
- return signal;
861
- }
862
-
863
- return signals.find(signalA=>signalA.number===number);
864
- };
865
-
866
- const signalsByNumber=getSignalsByNumber();main.signalsByNumber=signalsByNumber;
867
-
868
- const {signalsByName} = main;
869
-
870
- const getErrorPrefix = ({timedOut, timeout, errorCode, signal, signalDescription, exitCode, isCanceled}) => {
871
- if (timedOut) {
872
- return `timed out after ${timeout} milliseconds`;
873
- }
874
-
875
- if (isCanceled) {
876
- return 'was canceled';
877
- }
878
-
879
- if (errorCode !== undefined) {
880
- return `failed with ${errorCode}`;
881
- }
882
-
883
- if (signal !== undefined) {
884
- return `was killed with ${signal} (${signalDescription})`;
885
- }
886
-
887
- if (exitCode !== undefined) {
888
- return `failed with exit code ${exitCode}`;
889
- }
890
-
891
- return 'failed';
892
- };
893
-
894
- const makeError$1 = ({
895
- stdout,
896
- stderr,
897
- all,
898
- error,
899
- signal,
900
- exitCode,
901
- command,
902
- escapedCommand,
903
- timedOut,
904
- isCanceled,
905
- killed,
906
- parsed: {options: {timeout}}
907
- }) => {
908
- // `signal` and `exitCode` emitted on `spawned.on('exit')` event can be `null`.
909
- // We normalize them to `undefined`
910
- exitCode = exitCode === null ? undefined : exitCode;
911
- signal = signal === null ? undefined : signal;
912
- const signalDescription = signal === undefined ? undefined : signalsByName[signal].description;
913
-
914
- const errorCode = error && error.code;
915
-
916
- const prefix = getErrorPrefix({timedOut, timeout, errorCode, signal, signalDescription, exitCode, isCanceled});
917
- const execaMessage = `Command ${prefix}: ${command}`;
918
- const isError = Object.prototype.toString.call(error) === '[object Error]';
919
- const shortMessage = isError ? `${execaMessage}\n${error.message}` : execaMessage;
920
- const message = [shortMessage, stderr, stdout].filter(Boolean).join('\n');
921
-
922
- if (isError) {
923
- error.originalMessage = error.message;
924
- error.message = message;
925
- } else {
926
- error = new Error(message);
927
- }
928
-
929
- error.shortMessage = shortMessage;
930
- error.command = command;
931
- error.escapedCommand = escapedCommand;
932
- error.exitCode = exitCode;
933
- error.signal = signal;
934
- error.signalDescription = signalDescription;
935
- error.stdout = stdout;
936
- error.stderr = stderr;
937
-
938
- if (all !== undefined) {
939
- error.all = all;
940
- }
941
-
942
- if ('bufferedData' in error) {
943
- delete error.bufferedData;
944
- }
945
-
946
- error.failed = true;
947
- error.timedOut = Boolean(timedOut);
948
- error.isCanceled = isCanceled;
949
- error.killed = killed && !timedOut;
950
-
951
- return error;
952
- };
953
-
954
- var error = makeError$1;
955
-
956
- var stdio = {exports: {}};
957
-
958
- const aliases = ['stdin', 'stdout', 'stderr'];
959
-
960
- const hasAlias = options => aliases.some(alias => options[alias] !== undefined);
961
-
962
- const normalizeStdio$1 = options => {
963
- if (!options) {
964
- return;
965
- }
966
-
967
- const {stdio} = options;
968
-
969
- if (stdio === undefined) {
970
- return aliases.map(alias => options[alias]);
971
- }
972
-
973
- if (hasAlias(options)) {
974
- throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${aliases.map(alias => `\`${alias}\``).join(', ')}`);
975
- }
976
-
977
- if (typeof stdio === 'string') {
978
- return stdio;
979
- }
980
-
981
- if (!Array.isArray(stdio)) {
982
- throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof stdio}\``);
983
- }
984
-
985
- const length = Math.max(stdio.length, aliases.length);
986
- return Array.from({length}, (value, index) => stdio[index]);
987
- };
988
-
989
- stdio.exports = normalizeStdio$1;
990
-
991
- // `ipc` is pushed unless it is already present
992
- stdio.exports.node = options => {
993
- const stdio = normalizeStdio$1(options);
994
-
995
- if (stdio === 'ipc') {
996
- return 'ipc';
997
- }
998
-
999
- if (stdio === undefined || typeof stdio === 'string') {
1000
- return [stdio, stdio, stdio, 'ipc'];
1001
- }
1002
-
1003
- if (stdio.includes('ipc')) {
1004
- return stdio;
1005
- }
1006
-
1007
- return [...stdio, 'ipc'];
1008
- };
1009
-
1010
- const os = require$$0$1;
1011
- const onExit = signalExit.exports;
1012
-
1013
- const DEFAULT_FORCE_KILL_TIMEOUT = 1000 * 5;
1014
-
1015
- // Monkey-patches `childProcess.kill()` to add `forceKillAfterTimeout` behavior
1016
- const spawnedKill$1 = (kill, signal = 'SIGTERM', options = {}) => {
1017
- const killResult = kill(signal);
1018
- setKillTimeout(kill, signal, options, killResult);
1019
- return killResult;
1020
- };
1021
-
1022
- const setKillTimeout = (kill, signal, options, killResult) => {
1023
- if (!shouldForceKill(signal, options, killResult)) {
1024
- return;
1025
- }
1026
-
1027
- const timeout = getForceKillAfterTimeout(options);
1028
- const t = setTimeout(() => {
1029
- kill('SIGKILL');
1030
- }, timeout);
1031
-
1032
- // Guarded because there's no `.unref()` when `execa` is used in the renderer
1033
- // process in Electron. This cannot be tested since we don't run tests in
1034
- // Electron.
1035
- // istanbul ignore else
1036
- if (t.unref) {
1037
- t.unref();
1038
- }
1039
- };
1040
-
1041
- const shouldForceKill = (signal, {forceKillAfterTimeout}, killResult) => {
1042
- return isSigterm(signal) && forceKillAfterTimeout !== false && killResult;
1043
- };
1044
-
1045
- const isSigterm = signal => {
1046
- return signal === os.constants.signals.SIGTERM ||
1047
- (typeof signal === 'string' && signal.toUpperCase() === 'SIGTERM');
1048
- };
1049
-
1050
- const getForceKillAfterTimeout = ({forceKillAfterTimeout = true}) => {
1051
- if (forceKillAfterTimeout === true) {
1052
- return DEFAULT_FORCE_KILL_TIMEOUT;
1053
- }
1054
-
1055
- if (!Number.isFinite(forceKillAfterTimeout) || forceKillAfterTimeout < 0) {
1056
- throw new TypeError(`Expected the \`forceKillAfterTimeout\` option to be a non-negative integer, got \`${forceKillAfterTimeout}\` (${typeof forceKillAfterTimeout})`);
1057
- }
1058
-
1059
- return forceKillAfterTimeout;
1060
- };
1061
-
1062
- // `childProcess.cancel()`
1063
- const spawnedCancel$1 = (spawned, context) => {
1064
- const killResult = spawned.kill();
1065
-
1066
- if (killResult) {
1067
- context.isCanceled = true;
1068
- }
1069
- };
1070
-
1071
- const timeoutKill = (spawned, signal, reject) => {
1072
- spawned.kill(signal);
1073
- reject(Object.assign(new Error('Timed out'), {timedOut: true, signal}));
1074
- };
1075
-
1076
- // `timeout` option handling
1077
- const setupTimeout$1 = (spawned, {timeout, killSignal = 'SIGTERM'}, spawnedPromise) => {
1078
- if (timeout === 0 || timeout === undefined) {
1079
- return spawnedPromise;
1080
- }
1081
-
1082
- let timeoutId;
1083
- const timeoutPromise = new Promise((resolve, reject) => {
1084
- timeoutId = setTimeout(() => {
1085
- timeoutKill(spawned, killSignal, reject);
1086
- }, timeout);
1087
- });
1088
-
1089
- const safeSpawnedPromise = spawnedPromise.finally(() => {
1090
- clearTimeout(timeoutId);
1091
- });
1092
-
1093
- return Promise.race([timeoutPromise, safeSpawnedPromise]);
1094
- };
1095
-
1096
- const validateTimeout$1 = ({timeout}) => {
1097
- if (timeout !== undefined && (!Number.isFinite(timeout) || timeout < 0)) {
1098
- throw new TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${timeout}\` (${typeof timeout})`);
1099
- }
1100
- };
1101
-
1102
- // `cleanup` option handling
1103
- const setExitHandler$1 = async (spawned, {cleanup, detached}, timedPromise) => {
1104
- if (!cleanup || detached) {
1105
- return timedPromise;
1106
- }
1107
-
1108
- const removeExitHandler = onExit(() => {
1109
- spawned.kill();
1110
- });
1111
-
1112
- return timedPromise.finally(() => {
1113
- removeExitHandler();
1114
- });
1115
- };
1116
-
1117
- var kill = {
1118
- spawnedKill: spawnedKill$1,
1119
- spawnedCancel: spawnedCancel$1,
1120
- setupTimeout: setupTimeout$1,
1121
- validateTimeout: validateTimeout$1,
1122
- setExitHandler: setExitHandler$1
1123
- };
1124
-
1125
- const isStream$1 = stream =>
1126
- stream !== null &&
1127
- typeof stream === 'object' &&
1128
- typeof stream.pipe === 'function';
1129
-
1130
- isStream$1.writable = stream =>
1131
- isStream$1(stream) &&
1132
- stream.writable !== false &&
1133
- typeof stream._write === 'function' &&
1134
- typeof stream._writableState === 'object';
1135
-
1136
- isStream$1.readable = stream =>
1137
- isStream$1(stream) &&
1138
- stream.readable !== false &&
1139
- typeof stream._read === 'function' &&
1140
- typeof stream._readableState === 'object';
1141
-
1142
- isStream$1.duplex = stream =>
1143
- isStream$1.writable(stream) &&
1144
- isStream$1.readable(stream);
1145
-
1146
- isStream$1.transform = stream =>
1147
- isStream$1.duplex(stream) &&
1148
- typeof stream._transform === 'function';
1149
-
1150
- var isStream_1 = isStream$1;
1151
-
1152
- const isStream = isStream_1;
1153
- const getStream = getStream$1.exports;
1154
- const mergeStream = mergeStream$1;
1155
-
1156
- // `input` option
1157
- const handleInput$1 = (spawned, input) => {
1158
- // Checking for stdin is workaround for https://github.com/nodejs/node/issues/26852
1159
- // @todo remove `|| spawned.stdin === undefined` once we drop support for Node.js <=12.2.0
1160
- if (input === undefined || spawned.stdin === undefined) {
1161
- return;
1162
- }
1163
-
1164
- if (isStream(input)) {
1165
- input.pipe(spawned.stdin);
1166
- } else {
1167
- spawned.stdin.end(input);
1168
- }
1169
- };
1170
-
1171
- // `all` interleaves `stdout` and `stderr`
1172
- const makeAllStream$1 = (spawned, {all}) => {
1173
- if (!all || (!spawned.stdout && !spawned.stderr)) {
1174
- return;
1175
- }
1176
-
1177
- const mixed = mergeStream();
1178
-
1179
- if (spawned.stdout) {
1180
- mixed.add(spawned.stdout);
1181
- }
1182
-
1183
- if (spawned.stderr) {
1184
- mixed.add(spawned.stderr);
1185
- }
1186
-
1187
- return mixed;
1188
- };
1189
-
1190
- // On failure, `result.stdout|stderr|all` should contain the currently buffered stream
1191
- const getBufferedData = async (stream, streamPromise) => {
1192
- if (!stream) {
1193
- return;
1194
- }
1195
-
1196
- stream.destroy();
1197
-
1198
- try {
1199
- return await streamPromise;
1200
- } catch (error) {
1201
- return error.bufferedData;
1202
- }
1203
- };
1204
-
1205
- const getStreamPromise = (stream, {encoding, buffer, maxBuffer}) => {
1206
- if (!stream || !buffer) {
1207
- return;
1208
- }
1209
-
1210
- if (encoding) {
1211
- return getStream(stream, {encoding, maxBuffer});
1212
- }
1213
-
1214
- return getStream.buffer(stream, {maxBuffer});
1215
- };
1216
-
1217
- // Retrieve result of child process: exit code, signal, error, streams (stdout/stderr/all)
1218
- const getSpawnedResult$1 = async ({stdout, stderr, all}, {encoding, buffer, maxBuffer}, processDone) => {
1219
- const stdoutPromise = getStreamPromise(stdout, {encoding, buffer, maxBuffer});
1220
- const stderrPromise = getStreamPromise(stderr, {encoding, buffer, maxBuffer});
1221
- const allPromise = getStreamPromise(all, {encoding, buffer, maxBuffer: maxBuffer * 2});
1222
-
1223
- try {
1224
- return await Promise.all([processDone, stdoutPromise, stderrPromise, allPromise]);
1225
- } catch (error) {
1226
- return Promise.all([
1227
- {error, signal: error.signal, timedOut: error.timedOut},
1228
- getBufferedData(stdout, stdoutPromise),
1229
- getBufferedData(stderr, stderrPromise),
1230
- getBufferedData(all, allPromise)
1231
- ]);
1232
- }
1233
- };
1234
-
1235
- const validateInputSync$1 = ({input}) => {
1236
- if (isStream(input)) {
1237
- throw new TypeError('The `input` option cannot be a stream in sync mode');
1238
- }
1239
- };
1240
-
1241
- var stream = {
1242
- handleInput: handleInput$1,
1243
- makeAllStream: makeAllStream$1,
1244
- getSpawnedResult: getSpawnedResult$1,
1245
- validateInputSync: validateInputSync$1
1246
- };
1247
-
1248
- const nativePromisePrototype = (async () => {})().constructor.prototype;
1249
- const descriptors = ['then', 'catch', 'finally'].map(property => [
1250
- property,
1251
- Reflect.getOwnPropertyDescriptor(nativePromisePrototype, property)
1252
- ]);
1253
-
1254
- // The return value is a mixin of `childProcess` and `Promise`
1255
- const mergePromise$1 = (spawned, promise) => {
1256
- for (const [property, descriptor] of descriptors) {
1257
- // Starting the main `promise` is deferred to avoid consuming streams
1258
- const value = typeof promise === 'function' ?
1259
- (...args) => Reflect.apply(descriptor.value, promise(), args) :
1260
- descriptor.value.bind(promise);
1261
-
1262
- Reflect.defineProperty(spawned, property, {...descriptor, value});
1263
- }
1264
-
1265
- return spawned;
1266
- };
1267
-
1268
- // Use promises instead of `child_process` events
1269
- const getSpawnedPromise$1 = spawned => {
1270
- return new Promise((resolve, reject) => {
1271
- spawned.on('exit', (exitCode, signal) => {
1272
- resolve({exitCode, signal});
1273
- });
1274
-
1275
- spawned.on('error', error => {
1276
- reject(error);
1277
- });
1278
-
1279
- if (spawned.stdin) {
1280
- spawned.stdin.on('error', error => {
1281
- reject(error);
1282
- });
1283
- }
1284
- });
1285
- };
1286
-
1287
- var promise = {
1288
- mergePromise: mergePromise$1,
1289
- getSpawnedPromise: getSpawnedPromise$1
1290
- };
1291
-
1292
- const normalizeArgs = (file, args = []) => {
1293
- if (!Array.isArray(args)) {
1294
- return [file];
1295
- }
1296
-
1297
- return [file, ...args];
1298
- };
1299
-
1300
- const NO_ESCAPE_REGEXP = /^[\w.-]+$/;
1301
- const DOUBLE_QUOTES_REGEXP = /"/g;
1302
-
1303
- const escapeArg = arg => {
1304
- if (typeof arg !== 'string' || NO_ESCAPE_REGEXP.test(arg)) {
1305
- return arg;
1306
- }
1307
-
1308
- return `"${arg.replace(DOUBLE_QUOTES_REGEXP, '\\"')}"`;
1309
- };
1310
-
1311
- const joinCommand$1 = (file, args) => {
1312
- return normalizeArgs(file, args).join(' ');
1313
- };
1314
-
1315
- const getEscapedCommand$1 = (file, args) => {
1316
- return normalizeArgs(file, args).map(arg => escapeArg(arg)).join(' ');
1317
- };
1318
-
1319
- const SPACES_REGEXP = / +/g;
1320
-
1321
- // Handle `execa.command()`
1322
- const parseCommand$1 = command => {
1323
- const tokens = [];
1324
- for (const token of command.trim().split(SPACES_REGEXP)) {
1325
- // Allow spaces to be escaped by a backslash if not meant as a delimiter
1326
- const previousToken = tokens[tokens.length - 1];
1327
- if (previousToken && previousToken.endsWith('\\')) {
1328
- // Merge previous token with current one
1329
- tokens[tokens.length - 1] = `${previousToken.slice(0, -1)} ${token}`;
1330
- } else {
1331
- tokens.push(token);
1332
- }
1333
- }
1334
-
1335
- return tokens;
1336
- };
1337
-
1338
- var command = {
1339
- joinCommand: joinCommand$1,
1340
- getEscapedCommand: getEscapedCommand$1,
1341
- parseCommand: parseCommand$1
1342
- };
1343
-
1344
- const path = path$2;
1345
- const childProcess = childProcess$1;
1346
- const crossSpawn = crossSpawn$1.exports;
1347
- const stripFinalNewline = stripFinalNewline$1;
1348
- const npmRunPath = npmRunPath$1.exports;
1349
- const onetime = onetime$1.exports;
1350
- const makeError = error;
1351
- const normalizeStdio = stdio.exports;
1352
- const {spawnedKill, spawnedCancel, setupTimeout, validateTimeout, setExitHandler} = kill;
1353
- const {handleInput, getSpawnedResult, makeAllStream, validateInputSync} = stream;
1354
- const {mergePromise, getSpawnedPromise} = promise;
1355
- const {joinCommand, parseCommand, getEscapedCommand} = command;
1356
-
1357
- const DEFAULT_MAX_BUFFER = 1000 * 1000 * 100;
1358
-
1359
- const getEnv = ({env: envOption, extendEnv, preferLocal, localDir, execPath}) => {
1360
- const env = extendEnv ? {...process.env, ...envOption} : envOption;
1361
-
1362
- if (preferLocal) {
1363
- return npmRunPath.env({env, cwd: localDir, execPath});
1364
- }
1365
-
1366
- return env;
1367
- };
1368
-
1369
- const handleArguments = (file, args, options = {}) => {
1370
- const parsed = crossSpawn._parse(file, args, options);
1371
- file = parsed.command;
1372
- args = parsed.args;
1373
- options = parsed.options;
1374
-
1375
- options = {
1376
- maxBuffer: DEFAULT_MAX_BUFFER,
1377
- buffer: true,
1378
- stripFinalNewline: true,
1379
- extendEnv: true,
1380
- preferLocal: false,
1381
- localDir: options.cwd || process.cwd(),
1382
- execPath: process.execPath,
1383
- encoding: 'utf8',
1384
- reject: true,
1385
- cleanup: true,
1386
- all: false,
1387
- windowsHide: true,
1388
- ...options
1389
- };
1390
-
1391
- options.env = getEnv(options);
1392
-
1393
- options.stdio = normalizeStdio(options);
1394
-
1395
- if (process.platform === 'win32' && path.basename(file, '.exe') === 'cmd') {
1396
- // #116
1397
- args.unshift('/q');
1398
- }
1399
-
1400
- return {file, args, options, parsed};
1401
- };
1402
-
1403
- const handleOutput = (options, value, error) => {
1404
- if (typeof value !== 'string' && !Buffer.isBuffer(value)) {
1405
- // When `execa.sync()` errors, we normalize it to '' to mimic `execa()`
1406
- return error === undefined ? undefined : '';
1407
- }
1408
-
1409
- if (options.stripFinalNewline) {
1410
- return stripFinalNewline(value);
1411
- }
1412
-
1413
- return value;
1414
- };
1415
-
1416
- const execa = (file, args, options) => {
1417
- const parsed = handleArguments(file, args, options);
1418
- const command = joinCommand(file, args);
1419
- const escapedCommand = getEscapedCommand(file, args);
1420
-
1421
- validateTimeout(parsed.options);
1422
-
1423
- let spawned;
1424
- try {
1425
- spawned = childProcess.spawn(parsed.file, parsed.args, parsed.options);
1426
- } catch (error) {
1427
- // Ensure the returned error is always both a promise and a child process
1428
- const dummySpawned = new childProcess.ChildProcess();
1429
- const errorPromise = Promise.reject(makeError({
1430
- error,
1431
- stdout: '',
1432
- stderr: '',
1433
- all: '',
1434
- command,
1435
- escapedCommand,
1436
- parsed,
1437
- timedOut: false,
1438
- isCanceled: false,
1439
- killed: false
1440
- }));
1441
- return mergePromise(dummySpawned, errorPromise);
1442
- }
1443
-
1444
- const spawnedPromise = getSpawnedPromise(spawned);
1445
- const timedPromise = setupTimeout(spawned, parsed.options, spawnedPromise);
1446
- const processDone = setExitHandler(spawned, parsed.options, timedPromise);
1447
-
1448
- const context = {isCanceled: false};
1449
-
1450
- spawned.kill = spawnedKill.bind(null, spawned.kill.bind(spawned));
1451
- spawned.cancel = spawnedCancel.bind(null, spawned, context);
1452
-
1453
- const handlePromise = async () => {
1454
- const [{error, exitCode, signal, timedOut}, stdoutResult, stderrResult, allResult] = await getSpawnedResult(spawned, parsed.options, processDone);
1455
- const stdout = handleOutput(parsed.options, stdoutResult);
1456
- const stderr = handleOutput(parsed.options, stderrResult);
1457
- const all = handleOutput(parsed.options, allResult);
1458
-
1459
- if (error || exitCode !== 0 || signal !== null) {
1460
- const returnedError = makeError({
1461
- error,
1462
- exitCode,
1463
- signal,
1464
- stdout,
1465
- stderr,
1466
- all,
1467
- command,
1468
- escapedCommand,
1469
- parsed,
1470
- timedOut,
1471
- isCanceled: context.isCanceled,
1472
- killed: spawned.killed
1473
- });
1474
-
1475
- if (!parsed.options.reject) {
1476
- return returnedError;
1477
- }
1478
-
1479
- throw returnedError;
1480
- }
1481
-
1482
- return {
1483
- command,
1484
- escapedCommand,
1485
- exitCode: 0,
1486
- stdout,
1487
- stderr,
1488
- all,
1489
- failed: false,
1490
- timedOut: false,
1491
- isCanceled: false,
1492
- killed: false
1493
- };
1494
- };
1495
-
1496
- const handlePromiseOnce = onetime(handlePromise);
1497
-
1498
- handleInput(spawned, parsed.options.input);
1499
-
1500
- spawned.all = makeAllStream(spawned, parsed.options);
1501
-
1502
- return mergePromise(spawned, handlePromiseOnce);
1503
- };
1504
-
1505
- execa$2.exports = execa;
1506
-
1507
- execa$2.exports.sync = (file, args, options) => {
1508
- const parsed = handleArguments(file, args, options);
1509
- const command = joinCommand(file, args);
1510
- const escapedCommand = getEscapedCommand(file, args);
1511
-
1512
- validateInputSync(parsed.options);
1513
-
1514
- let result;
1515
- try {
1516
- result = childProcess.spawnSync(parsed.file, parsed.args, parsed.options);
1517
- } catch (error) {
1518
- throw makeError({
1519
- error,
1520
- stdout: '',
1521
- stderr: '',
1522
- all: '',
1523
- command,
1524
- escapedCommand,
1525
- parsed,
1526
- timedOut: false,
1527
- isCanceled: false,
1528
- killed: false
1529
- });
1530
- }
1531
-
1532
- const stdout = handleOutput(parsed.options, result.stdout, result.error);
1533
- const stderr = handleOutput(parsed.options, result.stderr, result.error);
1534
-
1535
- if (result.error || result.status !== 0 || result.signal !== null) {
1536
- const error = makeError({
1537
- stdout,
1538
- stderr,
1539
- error: result.error,
1540
- signal: result.signal,
1541
- exitCode: result.status,
1542
- command,
1543
- escapedCommand,
1544
- parsed,
1545
- timedOut: result.error && result.error.code === 'ETIMEDOUT',
1546
- isCanceled: false,
1547
- killed: result.signal !== null
1548
- });
1549
-
1550
- if (!parsed.options.reject) {
1551
- return error;
1552
- }
1553
-
1554
- throw error;
1555
- }
1556
-
1557
- return {
1558
- command,
1559
- escapedCommand,
1560
- exitCode: 0,
1561
- stdout,
1562
- stderr,
1563
- failed: false,
1564
- timedOut: false,
1565
- isCanceled: false,
1566
- killed: false
1567
- };
1568
- };
1569
-
1570
- execa$2.exports.command = (command, options) => {
1571
- const [file, ...args] = parseCommand(command);
1572
- return execa(file, args, options);
1573
- };
1574
-
1575
- execa$2.exports.commandSync = (command, options) => {
1576
- const [file, ...args] = parseCommand(command);
1577
- return execa.sync(file, args, options);
1578
- };
1579
-
1580
- execa$2.exports.node = (scriptPath, args, options = {}) => {
1581
- if (args && !Array.isArray(args) && typeof args === 'object') {
1582
- options = args;
1583
- args = [];
1584
- }
1585
-
1586
- const stdio = normalizeStdio.node(options);
1587
- const defaultExecArgv = process.execArgv.filter(arg => !arg.startsWith('--inspect'));
1588
-
1589
- const {
1590
- nodePath = process.execPath,
1591
- nodeOptions = defaultExecArgv
1592
- } = options;
1593
-
1594
- return execa(
1595
- nodePath,
1596
- [
1597
- ...nodeOptions,
1598
- scriptPath,
1599
- ...(Array.isArray(args) ? args : [])
1600
- ],
1601
- {
1602
- ...options,
1603
- stdin: undefined,
1604
- stdout: undefined,
1605
- stderr: undefined,
1606
- stdio,
1607
- shell: false
1608
- }
1609
- );
1610
- };
1611
-
1612
- var execa$1 = execa$2.exports;
1613
-
1614
- // src/detect.ts
1615
- var LOCKS = {
1616
- "pnpm-lock.yaml": "pnpm",
1617
- "yarn.lock": "yarn",
1618
- "package-lock.json": "npm"
1619
- };
1620
- async function detectPackageManager(cwd = process.cwd()) {
1621
- const result = await findUp(Object.keys(LOCKS), { cwd });
1622
- const agent = result ? LOCKS[path$2.basename(result)] : null;
1623
- return agent;
1624
- }
1625
- async function installPackage(names, options = {}) {
1626
- const agent = options.packageManager || await detectPackageManager(options.cwd) || "npm";
1627
- if (!Array.isArray(names))
1628
- names = [names];
1629
- const args = options.additionalArgs || [];
1630
- if (options.preferOffline)
1631
- args.unshift("--prefer-offline");
1632
- return execa$1(agent, [
1633
- agent === "yarn" ? "add" : "install",
1634
- options.dev ? "-D" : "",
1635
- ...args,
1636
- ...names
1637
- ].filter(Boolean), {
1638
- stdio: options.silent ? "ignore" : "inherit",
1639
- cwd: options.cwd
1640
- });
1641
- }
1642
-
1643
- export { detectPackageManager, installPackage };