vitest 0.12.8 → 0.13.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 (23) hide show
  1. package/dist/{chunk-api-setup.9ccd19b5.js → chunk-api-setup.554e8dcb.js} +107 -51
  2. package/dist/{chunk-constants.3570739f.js → chunk-constants.d60bb984.js} +1 -1
  3. package/dist/{chunk-defaults.7d81a6ca.js → chunk-defaults.c11f632f.js} +1 -1
  4. package/dist/{chunk-install-pkg.fd8d1022.js → chunk-install-pkg.8a034cf6.js} +1 -1
  5. package/dist/{chunk-integrations-globals.23cc66c3.js → chunk-integrations-globals.f7036c09.js} +7 -7
  6. package/dist/{chunk-runtime-chain.5021a6b6.js → chunk-runtime-chain.db87de48.js} +21 -10
  7. package/dist/{chunk-runtime-mocker.d26f8110.js → chunk-runtime-mocker.8436db18.js} +3 -3
  8. package/dist/chunk-runtime-rpc.6e6614a9.js +15 -0
  9. package/dist/{chunk-utils-global.2fab7e5c.js → chunk-utils-global.b9f8edf8.js} +34 -2
  10. package/dist/{chunk-utils-timers.da6ac0a6.js → chunk-utils-source-map.ded50c88.js} +14 -11
  11. package/dist/{chunk-vite-node-externalize.fc385bba.js → chunk-vite-node-externalize.0094db73.js} +8740 -8741
  12. package/dist/{chunk-vite-node-utils.46e2a803.js → chunk-vite-node-utils.6856b365.js} +1 -1
  13. package/dist/cli.js +16 -16
  14. package/dist/entry.js +6 -6
  15. package/dist/index.d.ts +61 -10
  16. package/dist/index.js +4 -4
  17. package/dist/node.d.ts +56 -0
  18. package/dist/node.js +20 -20
  19. package/dist/{vendor-entry.ca05c118.js → vendor-entry.6072d652.js} +11 -11
  20. package/dist/{vendor-index.6c69a0a8.js → vendor-index.42fcc02c.js} +407 -407
  21. package/dist/worker.js +5 -5
  22. package/package.json +37 -37
  23. package/dist/chunk-runtime-rpc.47bae3f9.js +0 -7
@@ -1,13 +1,343 @@
1
- import childProcess from 'child_process';
2
- import path$3 from 'path';
3
1
  import { c as commonjsGlobal } from './vendor-_commonjsHelpers.addc3445.js';
4
- import fs$1 from 'fs';
5
2
  import assert$1 from 'assert';
6
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
7
  import require$$0$2 from 'buffer';
8
8
  import require$$0 from 'stream';
9
9
  import require$$0$1 from 'util';
10
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
+ }
340
+
11
341
  var crossSpawn = {exports: {}};
12
342
 
13
343
  var windows;
@@ -456,7 +786,7 @@ const resolveCommand = resolveCommand_1;
456
786
  const escape = _escape;
457
787
  const readShebang = readShebang_1;
458
788
 
459
- const isWin$2 = process.platform === 'win32';
789
+ const isWin$1 = process.platform === 'win32';
460
790
  const isExecutableRegExp = /\.(?:com|exe)$/i;
461
791
  const isCmdShimRegExp = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
462
792
 
@@ -476,7 +806,7 @@ function detectShebang(parsed) {
476
806
  }
477
807
 
478
808
  function parseNonShell(parsed) {
479
- if (!isWin$2) {
809
+ if (!isWin$1) {
480
810
  return parsed;
481
811
  }
482
812
 
@@ -541,372 +871,102 @@ function parse$1(command, args, options) {
541
871
 
542
872
  var parse_1 = parse$1;
543
873
 
544
- const isWin$1 = process.platform === 'win32';
874
+ const isWin = process.platform === 'win32';
545
875
 
546
876
  function notFoundError(original, syscall) {
547
- return Object.assign(new Error(`${syscall} ${original.command} ENOENT`), {
548
- code: 'ENOENT',
549
- errno: 'ENOENT',
550
- syscall: `${syscall} ${original.command}`,
551
- path: original.command,
552
- spawnargs: original.args,
553
- });
554
- }
555
-
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
- }
877
+ return Object.assign(new Error(`${syscall} ${original.command} ENOENT`), {
878
+ code: 'ENOENT',
879
+ errno: 'ENOENT',
880
+ syscall: `${syscall} ${original.command}`,
881
+ path: original.command,
882
+ spawnargs: original.args,
883
+ });
884
+ }
759
885
 
760
- signalExit.exports = function (cb, opts) {
761
- /* istanbul ignore if */
762
- if (!processOk(commonjsGlobal.process)) {
763
- return function () {}
886
+ function hookChildProcess(cp, parsed) {
887
+ if (!isWin) {
888
+ return;
764
889
  }
765
- assert.equal(typeof cb, 'function', 'a callback must be provided for exit handler');
766
890
 
767
- if (loaded === false) {
768
- load();
769
- }
891
+ const originalEmit = cp.emit;
770
892
 
771
- var ev = 'exit';
772
- if (opts && opts.alwaysLast) {
773
- ev = 'afterexit';
774
- }
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);
775
899
 
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
- }
782
- };
783
- emitter.on(ev, cb);
900
+ if (err) {
901
+ return originalEmit.call(cp, 'error', err);
902
+ }
903
+ }
784
904
 
785
- return remove
786
- };
905
+ return originalEmit.apply(cp, arguments); // eslint-disable-line prefer-rest-params
906
+ };
907
+ }
787
908
 
788
- var unload = function unload () {
789
- if (!loaded || !processOk(commonjsGlobal.process)) {
790
- return
909
+ function verifyENOENT(status, parsed) {
910
+ if (isWin && status === 1 && !parsed.file) {
911
+ return notFoundError(parsed.original, 'spawn');
791
912
  }
792
- loaded = false;
793
913
 
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;
914
+ return null;
915
+ }
804
916
 
805
- var emit = function emit (event, code, signal) {
806
- /* istanbul ignore if */
807
- if (emitter.emitted[event]) {
808
- return
917
+ function verifyENOENTSync(status, parsed) {
918
+ if (isWin && status === 1 && !parsed.file) {
919
+ return notFoundError(parsed.original, 'spawnSync');
809
920
  }
810
- emitter.emitted[event] = true;
811
- emitter.emit(event, code, signal);
812
- };
813
921
 
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
- });
922
+ return null;
923
+ }
843
924
 
844
- signalExit.exports.signals = function () {
845
- return signals
846
- };
925
+ var enoent$1 = {
926
+ hookChildProcess,
927
+ verifyENOENT,
928
+ verifyENOENTSync,
929
+ notFoundError,
930
+ };
847
931
 
848
- var loaded = false;
932
+ const cp = childProcess;
933
+ const parse = parse_1;
934
+ const enoent = enoent$1;
849
935
 
850
- var load = function load () {
851
- if (loaded || !processOk(commonjsGlobal.process)) {
852
- return
853
- }
854
- loaded = true;
936
+ function spawn(command, args, options) {
937
+ // Parse the arguments
938
+ const parsed = parse(command, args, options);
855
939
 
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;
940
+ // Spawn the child process
941
+ const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);
861
942
 
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
- });
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);
870
946
 
871
- process$1.emit = processEmit;
872
- process$1.reallyExit = processReallyExit;
873
- };
874
- signalExit.exports.load = load;
947
+ return spawned;
948
+ }
875
949
 
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
- };
950
+ function spawnSync(command, args, options) {
951
+ // Parse the arguments
952
+ const parsed = parse(command, args, options);
889
953
 
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
- };
954
+ // Spawn the child process
955
+ const result = cp.spawnSync(parsed.command, parsed.args, parsed.options);
956
+
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);
959
+
960
+ return result;
908
961
  }
909
962
 
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
+
910
970
  var getStream$1 = {exports: {}};
911
971
 
912
972
  const {PassThrough: PassThroughStream} = require$$0;
@@ -1062,64 +1122,4 @@ var mergeStream = function (/*streams...*/) {
1062
1122
  }
1063
1123
  };
1064
1124
 
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 };