vitest 0.16.0 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. package/dist/{chunk-api-setup.f43cd039.mjs → chunk-api-setup.63babd7c.mjs} +4 -4
  2. package/dist/{chunk-constants.7b9cfc82.mjs → chunk-constants.8eb2ed35.mjs} +8 -2
  3. package/dist/chunk-env-node.26c72624.mjs +675 -0
  4. package/dist/{chunk-install-pkg.3fa50769.mjs → chunk-install-pkg.2dcb2c04.mjs} +1 -1
  5. package/dist/{chunk-integrations-globals.d0c363a6.mjs → chunk-integrations-globals.61e4d6ae.mjs} +8 -8
  6. package/dist/{chunk-runtime-chain.7103058b.mjs → chunk-runtime-chain.eb764dff.mjs} +55 -188
  7. package/dist/{chunk-runtime-mocker.110e3634.mjs → chunk-runtime-mocker.79ccc3de.mjs} +36 -62
  8. package/dist/{chunk-runtime-rpc.5e78af38.mjs → chunk-runtime-rpc.cc6a06a2.mjs} +1 -1
  9. package/dist/{chunk-utils-global.79a8b1cc.mjs → chunk-utils-global.1b22c4fd.mjs} +69 -5
  10. package/dist/{chunk-utils-source-map.2556cba8.mjs → chunk-utils-source-map.957e7756.mjs} +10 -24
  11. package/dist/{chunk-vite-node-externalize.58e10976.mjs → chunk-vite-node-externalize.0791f2ed.mjs} +2683 -2553
  12. package/dist/{chunk-vite-node-utils.7450fc0c.mjs → chunk-vite-node-utils.af8ead96.mjs} +28 -13
  13. package/dist/cli.mjs +15 -15
  14. package/dist/config.cjs +5 -1
  15. package/dist/config.d.ts +1 -1
  16. package/dist/config.mjs +5 -1
  17. package/dist/entry.mjs +8 -8
  18. package/dist/index.d.ts +223 -18
  19. package/dist/index.mjs +4 -4
  20. package/dist/node.d.ts +236 -38
  21. package/dist/node.mjs +16 -16
  22. package/dist/{vendor-entry.efeeaa5c.mjs → vendor-entry.78de67ab.mjs} +18 -424
  23. package/dist/{vendor-index.e5dc6622.mjs → vendor-index.4bf9c627.mjs} +405 -405
  24. package/dist/{vendor-index.98e769c1.mjs → vendor-index.de788b6a.mjs} +7 -7
  25. package/dist/worker.mjs +8 -8
  26. package/package.json +9 -4
  27. package/dist/chunk-defaults.dc6dc23d.mjs +0 -302
@@ -1,342 +1,12 @@
1
- import { c as commonjsGlobal } from './vendor-_commonjsHelpers.4da45ef5.mjs';
2
- import assert$1 from 'assert';
3
- import require$$2 from 'events';
4
- import childProcess from 'child_process';
5
- import path$3 from 'path';
6
- import fs$1 from 'fs';
7
- import require$$0$2 from 'buffer';
8
- import require$$0 from 'stream';
9
- import require$$0$1 from 'util';
10
-
11
- var onetime$1 = {exports: {}};
12
-
13
- var mimicFn$2 = {exports: {}};
14
-
15
- const mimicFn$1 = (to, from) => {
16
- for (const prop of Reflect.ownKeys(from)) {
17
- Object.defineProperty(to, prop, Object.getOwnPropertyDescriptor(from, prop));
18
- }
19
-
20
- return to;
21
- };
22
-
23
- mimicFn$2.exports = mimicFn$1;
24
- // TODO: Remove this for the next major release
25
- mimicFn$2.exports.default = mimicFn$1;
26
-
27
- const mimicFn = mimicFn$2.exports;
28
-
29
- const calledFunctions = new WeakMap();
30
-
31
- const onetime = (function_, options = {}) => {
32
- if (typeof function_ !== 'function') {
33
- throw new TypeError('Expected a function');
34
- }
35
-
36
- let returnValue;
37
- let callCount = 0;
38
- const functionName = function_.displayName || function_.name || '<anonymous>';
39
-
40
- const onetime = function (...arguments_) {
41
- calledFunctions.set(onetime, ++callCount);
42
-
43
- if (callCount === 1) {
44
- returnValue = function_.apply(this, arguments_);
45
- function_ = null;
46
- } else if (options.throw === true) {
47
- throw new Error(`Function \`${functionName}\` can only be called once`);
48
- }
49
-
50
- return returnValue;
51
- };
52
-
53
- mimicFn(onetime, function_);
54
- calledFunctions.set(onetime, callCount);
55
-
56
- return onetime;
57
- };
58
-
59
- onetime$1.exports = onetime;
60
- // TODO: Remove this for the next major release
61
- onetime$1.exports.default = onetime;
62
-
63
- onetime$1.exports.callCount = function_ => {
64
- if (!calledFunctions.has(function_)) {
65
- throw new Error(`The given function \`${function_.name}\` is not wrapped by the \`onetime\` package`);
66
- }
67
-
68
- return calledFunctions.get(function_);
69
- };
70
-
71
- var signalExit = {exports: {}};
72
-
73
- var signals$1 = {exports: {}};
74
-
75
- var hasRequiredSignals;
76
-
77
- function requireSignals () {
78
- if (hasRequiredSignals) return signals$1.exports;
79
- hasRequiredSignals = 1;
80
- (function (module) {
81
- // This is not the set of all possible signals.
82
- //
83
- // It IS, however, the set of all signals that trigger
84
- // an exit on either Linux or BSD systems. Linux is a
85
- // superset of the signal names supported on BSD, and
86
- // the unknown signals just fail to register, so we can
87
- // catch that easily enough.
88
- //
89
- // Don't bother with SIGKILL. It's uncatchable, which
90
- // means that we can't fire any callbacks anyway.
91
- //
92
- // If a user does happen to register a handler on a non-
93
- // fatal signal like SIGWINCH or something, and then
94
- // exit, it'll end up firing `process.emit('exit')`, so
95
- // the handler will be fired anyway.
96
- //
97
- // SIGBUS, SIGFPE, SIGSEGV and SIGILL, when not raised
98
- // artificially, inherently leave the process in a
99
- // state from which it is not safe to try and enter JS
100
- // listeners.
101
- module.exports = [
102
- 'SIGABRT',
103
- 'SIGALRM',
104
- 'SIGHUP',
105
- 'SIGINT',
106
- 'SIGTERM'
107
- ];
108
-
109
- if (process.platform !== 'win32') {
110
- module.exports.push(
111
- 'SIGVTALRM',
112
- 'SIGXCPU',
113
- 'SIGXFSZ',
114
- 'SIGUSR2',
115
- 'SIGTRAP',
116
- 'SIGSYS',
117
- 'SIGQUIT',
118
- 'SIGIOT'
119
- // should detect profiler and enable/disable accordingly.
120
- // see #21
121
- // 'SIGPROF'
122
- );
123
- }
124
-
125
- if (process.platform === 'linux') {
126
- module.exports.push(
127
- 'SIGIO',
128
- 'SIGPOLL',
129
- 'SIGPWR',
130
- 'SIGSTKFLT',
131
- 'SIGUNUSED'
132
- );
133
- }
134
- } (signals$1));
135
- return signals$1.exports;
136
- }
137
-
138
- // Note: since nyc uses this module to output coverage, any lines
139
- // that are in the direct sync flow of nyc's outputCoverage are
140
- // ignored, since we can never get coverage for them.
141
- // grab a reference to node's real process object right away
142
- var process$1 = commonjsGlobal.process;
143
-
144
- const processOk = function (process) {
145
- return process &&
146
- typeof process === 'object' &&
147
- typeof process.removeListener === 'function' &&
148
- typeof process.emit === 'function' &&
149
- typeof process.reallyExit === 'function' &&
150
- typeof process.listeners === 'function' &&
151
- typeof process.kill === 'function' &&
152
- typeof process.pid === 'number' &&
153
- typeof process.on === 'function'
154
- };
155
-
156
- // some kind of non-node environment, just no-op
157
- /* istanbul ignore if */
158
- if (!processOk(process$1)) {
159
- signalExit.exports = function () {
160
- return function () {}
161
- };
162
- } else {
163
- var assert = assert$1;
164
- var signals = requireSignals();
165
- var isWin$2 = /^win/i.test(process$1.platform);
166
-
167
- var EE = require$$2;
168
- /* istanbul ignore if */
169
- if (typeof EE !== 'function') {
170
- EE = EE.EventEmitter;
171
- }
172
-
173
- var emitter;
174
- if (process$1.__signal_exit_emitter__) {
175
- emitter = process$1.__signal_exit_emitter__;
176
- } else {
177
- emitter = process$1.__signal_exit_emitter__ = new EE();
178
- emitter.count = 0;
179
- emitter.emitted = {};
180
- }
181
-
182
- // Because this emitter is a global, we have to check to see if a
183
- // previous version of this library failed to enable infinite listeners.
184
- // I know what you're about to say. But literally everything about
185
- // signal-exit is a compromise with evil. Get used to it.
186
- if (!emitter.infinite) {
187
- emitter.setMaxListeners(Infinity);
188
- emitter.infinite = true;
189
- }
190
-
191
- signalExit.exports = function (cb, opts) {
192
- /* istanbul ignore if */
193
- if (!processOk(commonjsGlobal.process)) {
194
- return function () {}
195
- }
196
- assert.equal(typeof cb, 'function', 'a callback must be provided for exit handler');
197
-
198
- if (loaded === false) {
199
- load();
200
- }
201
-
202
- var ev = 'exit';
203
- if (opts && opts.alwaysLast) {
204
- ev = 'afterexit';
205
- }
206
-
207
- var remove = function () {
208
- emitter.removeListener(ev, cb);
209
- if (emitter.listeners('exit').length === 0 &&
210
- emitter.listeners('afterexit').length === 0) {
211
- unload();
212
- }
213
- };
214
- emitter.on(ev, cb);
215
-
216
- return remove
217
- };
218
-
219
- var unload = function unload () {
220
- if (!loaded || !processOk(commonjsGlobal.process)) {
221
- return
222
- }
223
- loaded = false;
224
-
225
- signals.forEach(function (sig) {
226
- try {
227
- process$1.removeListener(sig, sigListeners[sig]);
228
- } catch (er) {}
229
- });
230
- process$1.emit = originalProcessEmit;
231
- process$1.reallyExit = originalProcessReallyExit;
232
- emitter.count -= 1;
233
- };
234
- signalExit.exports.unload = unload;
235
-
236
- var emit = function emit (event, code, signal) {
237
- /* istanbul ignore if */
238
- if (emitter.emitted[event]) {
239
- return
240
- }
241
- emitter.emitted[event] = true;
242
- emitter.emit(event, code, signal);
243
- };
244
-
245
- // { <signal>: <listener fn>, ... }
246
- var sigListeners = {};
247
- signals.forEach(function (sig) {
248
- sigListeners[sig] = function listener () {
249
- /* istanbul ignore if */
250
- if (!processOk(commonjsGlobal.process)) {
251
- return
252
- }
253
- // If there are no other listeners, an exit is coming!
254
- // Simplest way: remove us and then re-send the signal.
255
- // We know that this will kill the process, so we can
256
- // safely emit now.
257
- var listeners = process$1.listeners(sig);
258
- if (listeners.length === emitter.count) {
259
- unload();
260
- emit('exit', null, sig);
261
- /* istanbul ignore next */
262
- emit('afterexit', null, sig);
263
- /* istanbul ignore next */
264
- if (isWin$2 && sig === 'SIGHUP') {
265
- // "SIGHUP" throws an `ENOSYS` error on Windows,
266
- // so use a supported signal instead
267
- sig = 'SIGINT';
268
- }
269
- /* istanbul ignore next */
270
- process$1.kill(process$1.pid, sig);
271
- }
272
- };
273
- });
274
-
275
- signalExit.exports.signals = function () {
276
- return signals
277
- };
278
-
279
- var loaded = false;
280
-
281
- var load = function load () {
282
- if (loaded || !processOk(commonjsGlobal.process)) {
283
- return
284
- }
285
- loaded = true;
286
-
287
- // This is the number of onSignalExit's that are in play.
288
- // It's important so that we can count the correct number of
289
- // listeners on signals, and don't wait for the other one to
290
- // handle it instead of us.
291
- emitter.count += 1;
292
-
293
- signals = signals.filter(function (sig) {
294
- try {
295
- process$1.on(sig, sigListeners[sig]);
296
- return true
297
- } catch (er) {
298
- return false
299
- }
300
- });
301
-
302
- process$1.emit = processEmit;
303
- process$1.reallyExit = processReallyExit;
304
- };
305
- signalExit.exports.load = load;
306
-
307
- var originalProcessReallyExit = process$1.reallyExit;
308
- var processReallyExit = function processReallyExit (code) {
309
- /* istanbul ignore if */
310
- if (!processOk(commonjsGlobal.process)) {
311
- return
312
- }
313
- process$1.exitCode = code || /* istanbul ignore next */ 0;
314
- emit('exit', process$1.exitCode, null);
315
- /* istanbul ignore next */
316
- emit('afterexit', process$1.exitCode, null);
317
- /* istanbul ignore next */
318
- originalProcessReallyExit.call(process$1, process$1.exitCode);
319
- };
320
-
321
- var originalProcessEmit = process$1.emit;
322
- var processEmit = function processEmit (ev, arg) {
323
- if (ev === 'exit' && processOk(commonjsGlobal.process)) {
324
- /* istanbul ignore else */
325
- if (arg !== undefined) {
326
- process$1.exitCode = arg;
327
- }
328
- var ret = originalProcessEmit.apply(this, arguments);
329
- /* istanbul ignore next */
330
- emit('exit', process$1.exitCode, null);
331
- /* istanbul ignore next */
332
- emit('afterexit', process$1.exitCode, null);
333
- /* istanbul ignore next */
334
- return ret
335
- } else {
336
- return originalProcessEmit.apply(this, arguments)
337
- }
338
- };
339
- }
1
+ import childProcess from 'child_process';
2
+ import path$3 from 'path';
3
+ import { c as commonjsGlobal } from './vendor-_commonjsHelpers.4da45ef5.mjs';
4
+ import fs$1 from 'fs';
5
+ import assert$1 from 'assert';
6
+ import require$$2 from 'events';
7
+ import require$$0$2 from 'buffer';
8
+ import require$$0 from 'stream';
9
+ import require$$0$1 from 'util';
340
10
 
341
11
  var crossSpawn = {exports: {}};
342
12
 
@@ -786,7 +456,7 @@ const resolveCommand = resolveCommand_1;
786
456
  const escape = _escape;
787
457
  const readShebang = readShebang_1;
788
458
 
789
- const isWin$1 = process.platform === 'win32';
459
+ const isWin$2 = process.platform === 'win32';
790
460
  const isExecutableRegExp = /\.(?:com|exe)$/i;
791
461
  const isCmdShimRegExp = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
792
462
 
@@ -806,7 +476,7 @@ function detectShebang(parsed) {
806
476
  }
807
477
 
808
478
  function parseNonShell(parsed) {
809
- if (!isWin$1) {
479
+ if (!isWin$2) {
810
480
  return parsed;
811
481
  }
812
482
 
@@ -871,7 +541,7 @@ function parse$1(command, args, options) {
871
541
 
872
542
  var parse_1 = parse$1;
873
543
 
874
- const isWin = process.platform === 'win32';
544
+ const isWin$1 = process.platform === 'win32';
875
545
 
876
546
  function notFoundError(original, syscall) {
877
547
  return Object.assign(new Error(`${syscall} ${original.command} ENOENT`), {
@@ -883,90 +553,360 @@ function notFoundError(original, syscall) {
883
553
  });
884
554
  }
885
555
 
886
- function hookChildProcess(cp, parsed) {
887
- if (!isWin) {
888
- return;
556
+ function hookChildProcess(cp, parsed) {
557
+ if (!isWin$1) {
558
+ return;
559
+ }
560
+
561
+ const originalEmit = cp.emit;
562
+
563
+ cp.emit = function (name, arg1) {
564
+ // If emitting "exit" event and exit code is 1, we need to check if
565
+ // the command exists and emit an "error" instead
566
+ // See https://github.com/IndigoUnited/node-cross-spawn/issues/16
567
+ if (name === 'exit') {
568
+ const err = verifyENOENT(arg1, parsed);
569
+
570
+ if (err) {
571
+ return originalEmit.call(cp, 'error', err);
572
+ }
573
+ }
574
+
575
+ return originalEmit.apply(cp, arguments); // eslint-disable-line prefer-rest-params
576
+ };
577
+ }
578
+
579
+ function verifyENOENT(status, parsed) {
580
+ if (isWin$1 && status === 1 && !parsed.file) {
581
+ return notFoundError(parsed.original, 'spawn');
582
+ }
583
+
584
+ return null;
585
+ }
586
+
587
+ function verifyENOENTSync(status, parsed) {
588
+ if (isWin$1 && status === 1 && !parsed.file) {
589
+ return notFoundError(parsed.original, 'spawnSync');
590
+ }
591
+
592
+ return null;
593
+ }
594
+
595
+ var enoent$1 = {
596
+ hookChildProcess,
597
+ verifyENOENT,
598
+ verifyENOENTSync,
599
+ notFoundError,
600
+ };
601
+
602
+ const cp = childProcess;
603
+ const parse = parse_1;
604
+ const enoent = enoent$1;
605
+
606
+ function spawn(command, args, options) {
607
+ // Parse the arguments
608
+ const parsed = parse(command, args, options);
609
+
610
+ // Spawn the child process
611
+ const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);
612
+
613
+ // Hook into child process "exit" event to emit an error if the command
614
+ // does not exists, see: https://github.com/IndigoUnited/node-cross-spawn/issues/16
615
+ enoent.hookChildProcess(spawned, parsed);
616
+
617
+ return spawned;
618
+ }
619
+
620
+ function spawnSync(command, args, options) {
621
+ // Parse the arguments
622
+ const parsed = parse(command, args, options);
623
+
624
+ // Spawn the child process
625
+ const result = cp.spawnSync(parsed.command, parsed.args, parsed.options);
626
+
627
+ // Analyze if the command does not exist, see: https://github.com/IndigoUnited/node-cross-spawn/issues/16
628
+ result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
629
+
630
+ return result;
631
+ }
632
+
633
+ crossSpawn.exports = spawn;
634
+ crossSpawn.exports.spawn = spawn;
635
+ crossSpawn.exports.sync = spawnSync;
636
+
637
+ crossSpawn.exports._parse = parse;
638
+ crossSpawn.exports._enoent = enoent;
639
+
640
+ var signalExit = {exports: {}};
641
+
642
+ var signals$1 = {exports: {}};
643
+
644
+ var hasRequiredSignals;
645
+
646
+ function requireSignals () {
647
+ if (hasRequiredSignals) return signals$1.exports;
648
+ hasRequiredSignals = 1;
649
+ (function (module) {
650
+ // This is not the set of all possible signals.
651
+ //
652
+ // It IS, however, the set of all signals that trigger
653
+ // an exit on either Linux or BSD systems. Linux is a
654
+ // superset of the signal names supported on BSD, and
655
+ // the unknown signals just fail to register, so we can
656
+ // catch that easily enough.
657
+ //
658
+ // Don't bother with SIGKILL. It's uncatchable, which
659
+ // means that we can't fire any callbacks anyway.
660
+ //
661
+ // If a user does happen to register a handler on a non-
662
+ // fatal signal like SIGWINCH or something, and then
663
+ // exit, it'll end up firing `process.emit('exit')`, so
664
+ // the handler will be fired anyway.
665
+ //
666
+ // SIGBUS, SIGFPE, SIGSEGV and SIGILL, when not raised
667
+ // artificially, inherently leave the process in a
668
+ // state from which it is not safe to try and enter JS
669
+ // listeners.
670
+ module.exports = [
671
+ 'SIGABRT',
672
+ 'SIGALRM',
673
+ 'SIGHUP',
674
+ 'SIGINT',
675
+ 'SIGTERM'
676
+ ];
677
+
678
+ if (process.platform !== 'win32') {
679
+ module.exports.push(
680
+ 'SIGVTALRM',
681
+ 'SIGXCPU',
682
+ 'SIGXFSZ',
683
+ 'SIGUSR2',
684
+ 'SIGTRAP',
685
+ 'SIGSYS',
686
+ 'SIGQUIT',
687
+ 'SIGIOT'
688
+ // should detect profiler and enable/disable accordingly.
689
+ // see #21
690
+ // 'SIGPROF'
691
+ );
692
+ }
693
+
694
+ if (process.platform === 'linux') {
695
+ module.exports.push(
696
+ 'SIGIO',
697
+ 'SIGPOLL',
698
+ 'SIGPWR',
699
+ 'SIGSTKFLT',
700
+ 'SIGUNUSED'
701
+ );
702
+ }
703
+ } (signals$1));
704
+ return signals$1.exports;
705
+ }
706
+
707
+ // Note: since nyc uses this module to output coverage, any lines
708
+ // that are in the direct sync flow of nyc's outputCoverage are
709
+ // ignored, since we can never get coverage for them.
710
+ // grab a reference to node's real process object right away
711
+ var process$1 = commonjsGlobal.process;
712
+
713
+ const processOk = function (process) {
714
+ return process &&
715
+ typeof process === 'object' &&
716
+ typeof process.removeListener === 'function' &&
717
+ typeof process.emit === 'function' &&
718
+ typeof process.reallyExit === 'function' &&
719
+ typeof process.listeners === 'function' &&
720
+ typeof process.kill === 'function' &&
721
+ typeof process.pid === 'number' &&
722
+ typeof process.on === 'function'
723
+ };
724
+
725
+ // some kind of non-node environment, just no-op
726
+ /* istanbul ignore if */
727
+ if (!processOk(process$1)) {
728
+ signalExit.exports = function () {
729
+ return function () {}
730
+ };
731
+ } else {
732
+ var assert = assert$1;
733
+ var signals = requireSignals();
734
+ var isWin = /^win/i.test(process$1.platform);
735
+
736
+ var EE = require$$2;
737
+ /* istanbul ignore if */
738
+ if (typeof EE !== 'function') {
739
+ EE = EE.EventEmitter;
740
+ }
741
+
742
+ var emitter;
743
+ if (process$1.__signal_exit_emitter__) {
744
+ emitter = process$1.__signal_exit_emitter__;
745
+ } else {
746
+ emitter = process$1.__signal_exit_emitter__ = new EE();
747
+ emitter.count = 0;
748
+ emitter.emitted = {};
749
+ }
750
+
751
+ // Because this emitter is a global, we have to check to see if a
752
+ // previous version of this library failed to enable infinite listeners.
753
+ // I know what you're about to say. But literally everything about
754
+ // signal-exit is a compromise with evil. Get used to it.
755
+ if (!emitter.infinite) {
756
+ emitter.setMaxListeners(Infinity);
757
+ emitter.infinite = true;
758
+ }
759
+
760
+ signalExit.exports = function (cb, opts) {
761
+ /* istanbul ignore if */
762
+ if (!processOk(commonjsGlobal.process)) {
763
+ return function () {}
889
764
  }
765
+ assert.equal(typeof cb, 'function', 'a callback must be provided for exit handler');
890
766
 
891
- const originalEmit = cp.emit;
892
-
893
- cp.emit = function (name, arg1) {
894
- // If emitting "exit" event and exit code is 1, we need to check if
895
- // the command exists and emit an "error" instead
896
- // See https://github.com/IndigoUnited/node-cross-spawn/issues/16
897
- if (name === 'exit') {
898
- const err = verifyENOENT(arg1, parsed);
767
+ if (loaded === false) {
768
+ load();
769
+ }
899
770
 
900
- if (err) {
901
- return originalEmit.call(cp, 'error', err);
902
- }
903
- }
771
+ var ev = 'exit';
772
+ if (opts && opts.alwaysLast) {
773
+ ev = 'afterexit';
774
+ }
904
775
 
905
- return originalEmit.apply(cp, arguments); // eslint-disable-line prefer-rest-params
776
+ var remove = function () {
777
+ emitter.removeListener(ev, cb);
778
+ if (emitter.listeners('exit').length === 0 &&
779
+ emitter.listeners('afterexit').length === 0) {
780
+ unload();
781
+ }
906
782
  };
907
- }
908
-
909
- function verifyENOENT(status, parsed) {
910
- if (isWin && status === 1 && !parsed.file) {
911
- return notFoundError(parsed.original, 'spawn');
912
- }
783
+ emitter.on(ev, cb);
913
784
 
914
- return null;
915
- }
785
+ return remove
786
+ };
916
787
 
917
- function verifyENOENTSync(status, parsed) {
918
- if (isWin && status === 1 && !parsed.file) {
919
- return notFoundError(parsed.original, 'spawnSync');
788
+ var unload = function unload () {
789
+ if (!loaded || !processOk(commonjsGlobal.process)) {
790
+ return
920
791
  }
792
+ loaded = false;
921
793
 
922
- return null;
923
- }
794
+ signals.forEach(function (sig) {
795
+ try {
796
+ process$1.removeListener(sig, sigListeners[sig]);
797
+ } catch (er) {}
798
+ });
799
+ process$1.emit = originalProcessEmit;
800
+ process$1.reallyExit = originalProcessReallyExit;
801
+ emitter.count -= 1;
802
+ };
803
+ signalExit.exports.unload = unload;
924
804
 
925
- var enoent$1 = {
926
- hookChildProcess,
927
- verifyENOENT,
928
- verifyENOENTSync,
929
- notFoundError,
930
- };
805
+ var emit = function emit (event, code, signal) {
806
+ /* istanbul ignore if */
807
+ if (emitter.emitted[event]) {
808
+ return
809
+ }
810
+ emitter.emitted[event] = true;
811
+ emitter.emit(event, code, signal);
812
+ };
931
813
 
932
- const cp = childProcess;
933
- const parse = parse_1;
934
- const enoent = enoent$1;
814
+ // { <signal>: <listener fn>, ... }
815
+ var sigListeners = {};
816
+ signals.forEach(function (sig) {
817
+ sigListeners[sig] = function listener () {
818
+ /* istanbul ignore if */
819
+ if (!processOk(commonjsGlobal.process)) {
820
+ return
821
+ }
822
+ // If there are no other listeners, an exit is coming!
823
+ // Simplest way: remove us and then re-send the signal.
824
+ // We know that this will kill the process, so we can
825
+ // safely emit now.
826
+ var listeners = process$1.listeners(sig);
827
+ if (listeners.length === emitter.count) {
828
+ unload();
829
+ emit('exit', null, sig);
830
+ /* istanbul ignore next */
831
+ emit('afterexit', null, sig);
832
+ /* istanbul ignore next */
833
+ if (isWin && sig === 'SIGHUP') {
834
+ // "SIGHUP" throws an `ENOSYS` error on Windows,
835
+ // so use a supported signal instead
836
+ sig = 'SIGINT';
837
+ }
838
+ /* istanbul ignore next */
839
+ process$1.kill(process$1.pid, sig);
840
+ }
841
+ };
842
+ });
935
843
 
936
- function spawn(command, args, options) {
937
- // Parse the arguments
938
- const parsed = parse(command, args, options);
844
+ signalExit.exports.signals = function () {
845
+ return signals
846
+ };
939
847
 
940
- // Spawn the child process
941
- const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);
848
+ var loaded = false;
942
849
 
943
- // Hook into child process "exit" event to emit an error if the command
944
- // does not exists, see: https://github.com/IndigoUnited/node-cross-spawn/issues/16
945
- enoent.hookChildProcess(spawned, parsed);
850
+ var load = function load () {
851
+ if (loaded || !processOk(commonjsGlobal.process)) {
852
+ return
853
+ }
854
+ loaded = true;
946
855
 
947
- return spawned;
948
- }
856
+ // This is the number of onSignalExit's that are in play.
857
+ // It's important so that we can count the correct number of
858
+ // listeners on signals, and don't wait for the other one to
859
+ // handle it instead of us.
860
+ emitter.count += 1;
949
861
 
950
- function spawnSync(command, args, options) {
951
- // Parse the arguments
952
- const parsed = parse(command, args, options);
862
+ signals = signals.filter(function (sig) {
863
+ try {
864
+ process$1.on(sig, sigListeners[sig]);
865
+ return true
866
+ } catch (er) {
867
+ return false
868
+ }
869
+ });
953
870
 
954
- // Spawn the child process
955
- const result = cp.spawnSync(parsed.command, parsed.args, parsed.options);
871
+ process$1.emit = processEmit;
872
+ process$1.reallyExit = processReallyExit;
873
+ };
874
+ signalExit.exports.load = load;
956
875
 
957
- // Analyze if the command does not exist, see: https://github.com/IndigoUnited/node-cross-spawn/issues/16
958
- result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
876
+ var originalProcessReallyExit = process$1.reallyExit;
877
+ var processReallyExit = function processReallyExit (code) {
878
+ /* istanbul ignore if */
879
+ if (!processOk(commonjsGlobal.process)) {
880
+ return
881
+ }
882
+ process$1.exitCode = code || /* istanbul ignore next */ 0;
883
+ emit('exit', process$1.exitCode, null);
884
+ /* istanbul ignore next */
885
+ emit('afterexit', process$1.exitCode, null);
886
+ /* istanbul ignore next */
887
+ originalProcessReallyExit.call(process$1, process$1.exitCode);
888
+ };
959
889
 
960
- return result;
890
+ var originalProcessEmit = process$1.emit;
891
+ var processEmit = function processEmit (ev, arg) {
892
+ if (ev === 'exit' && processOk(commonjsGlobal.process)) {
893
+ /* istanbul ignore else */
894
+ if (arg !== undefined) {
895
+ process$1.exitCode = arg;
896
+ }
897
+ var ret = originalProcessEmit.apply(this, arguments);
898
+ /* istanbul ignore next */
899
+ emit('exit', process$1.exitCode, null);
900
+ /* istanbul ignore next */
901
+ emit('afterexit', process$1.exitCode, null);
902
+ /* istanbul ignore next */
903
+ return ret
904
+ } else {
905
+ return originalProcessEmit.apply(this, arguments)
906
+ }
907
+ };
961
908
  }
962
909
 
963
- crossSpawn.exports = spawn;
964
- crossSpawn.exports.spawn = spawn;
965
- crossSpawn.exports.sync = spawnSync;
966
-
967
- crossSpawn.exports._parse = parse;
968
- crossSpawn.exports._enoent = enoent;
969
-
970
910
  var getStream$1 = {exports: {}};
971
911
 
972
912
  const {PassThrough: PassThroughStream} = require$$0;
@@ -1122,4 +1062,64 @@ var mergeStream = function (/*streams...*/) {
1122
1062
  }
1123
1063
  };
1124
1064
 
1065
+ var onetime$1 = {exports: {}};
1066
+
1067
+ var mimicFn$2 = {exports: {}};
1068
+
1069
+ const mimicFn$1 = (to, from) => {
1070
+ for (const prop of Reflect.ownKeys(from)) {
1071
+ Object.defineProperty(to, prop, Object.getOwnPropertyDescriptor(from, prop));
1072
+ }
1073
+
1074
+ return to;
1075
+ };
1076
+
1077
+ mimicFn$2.exports = mimicFn$1;
1078
+ // TODO: Remove this for the next major release
1079
+ mimicFn$2.exports.default = mimicFn$1;
1080
+
1081
+ const mimicFn = mimicFn$2.exports;
1082
+
1083
+ const calledFunctions = new WeakMap();
1084
+
1085
+ const onetime = (function_, options = {}) => {
1086
+ if (typeof function_ !== 'function') {
1087
+ throw new TypeError('Expected a function');
1088
+ }
1089
+
1090
+ let returnValue;
1091
+ let callCount = 0;
1092
+ const functionName = function_.displayName || function_.name || '<anonymous>';
1093
+
1094
+ const onetime = function (...arguments_) {
1095
+ calledFunctions.set(onetime, ++callCount);
1096
+
1097
+ if (callCount === 1) {
1098
+ returnValue = function_.apply(this, arguments_);
1099
+ function_ = null;
1100
+ } else if (options.throw === true) {
1101
+ throw new Error(`Function \`${functionName}\` can only be called once`);
1102
+ }
1103
+
1104
+ return returnValue;
1105
+ };
1106
+
1107
+ mimicFn(onetime, function_);
1108
+ calledFunctions.set(onetime, callCount);
1109
+
1110
+ return onetime;
1111
+ };
1112
+
1113
+ onetime$1.exports = onetime;
1114
+ // TODO: Remove this for the next major release
1115
+ onetime$1.exports.default = onetime;
1116
+
1117
+ onetime$1.exports.callCount = function_ => {
1118
+ if (!calledFunctions.has(function_)) {
1119
+ throw new Error(`The given function \`${function_.name}\` is not wrapped by the \`onetime\` package`);
1120
+ }
1121
+
1122
+ return calledFunctions.get(function_);
1123
+ };
1124
+
1125
1125
  export { crossSpawn as c, getStream$1 as g, mergeStream as m, onetime$1 as o, pathKey$1 as p, signalExit as s };