vitest 1.0.0-beta.2 → 1.0.0-beta.3

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 (39) hide show
  1. package/LICENSE.md +0 -29
  2. package/dist/browser.d.ts +1 -1
  3. package/dist/child.js +9 -4
  4. package/dist/{chunk-api-setup.5d9a93c7.js → chunk-api-setup.37a43981.js} +0 -2
  5. package/dist/{chunk-install-pkg.43d58972.js → chunk-install-pkg.6349b322.js} +10 -12
  6. package/dist/{chunk-node-git.2f1df48f.js → chunk-node-git.6c12e560.js} +1 -1
  7. package/dist/cli-wrapper.js +1 -1
  8. package/dist/cli.js +11 -18
  9. package/dist/config.d.ts +2 -2
  10. package/dist/coverage.d.ts +1 -1
  11. package/dist/coverage.js +2 -2
  12. package/dist/entry-vm.js +1 -1
  13. package/dist/entry.js +1 -1
  14. package/dist/environments.d.ts +1 -1
  15. package/dist/environments.js +1 -13
  16. package/dist/execute.d.ts +1 -1
  17. package/dist/execute.js +1 -1
  18. package/dist/index.d.ts +5 -5
  19. package/dist/node.d.ts +5 -3
  20. package/dist/node.js +14 -16
  21. package/dist/{reporters-d10f25e1.d.ts → reporters-1678fe04.d.ts} +62 -30
  22. package/dist/reporters.d.ts +1 -1
  23. package/dist/reporters.js +1 -1
  24. package/dist/runners.d.ts +3 -2
  25. package/dist/runners.js +32 -35
  26. package/dist/{suite-919dd548.d.ts → suite-0579b50d.d.ts} +1 -1
  27. package/dist/suite.d.ts +2 -2
  28. package/dist/{vendor-environments.094f240c.js → vendor-environments.dcc4a34e.js} +4 -37
  29. package/dist/{vendor-execute.07d1a420.js → vendor-execute.e6e4e89b.js} +1 -0
  30. package/dist/{vendor-index.d36f5516.js → vendor-index.3d079eea.js} +6 -1
  31. package/dist/{vendor-index.e006069f.js → vendor-index.8efe7746.js} +371 -371
  32. package/dist/{vendor-index.0b5b3600.js → vendor-loader.9c966f23.js} +36 -9
  33. package/dist/{vendor-node.e5a35bfe.js → vendor-node.327f8f1f.js} +1928 -1953
  34. package/dist/{vendor-reporters.2953082e.js → vendor-reporters.b9600369.js} +40 -23
  35. package/dist/vm.js +9 -4
  36. package/dist/worker.js +9 -4
  37. package/package.json +11 -27
  38. package/dist/loader.js +0 -100
  39. package/dist/vendor-index.98139333.js +0 -129
@@ -3,12 +3,12 @@ import path$3 from 'node:path';
3
3
  import childProcess, { ChildProcess } from 'node:child_process';
4
4
  import process$2 from 'node:process';
5
5
  import { c as commonjsGlobal, g as getDefaultExportFromCjs } from './vendor-_commonjsHelpers.7d1333e8.js';
6
- import require$$0$1 from 'child_process';
6
+ import require$$0 from 'child_process';
7
7
  import f from 'path';
8
8
  import $ from 'fs';
9
9
  import url from 'node:url';
10
10
  import nodeos__default, { constants } from 'node:os';
11
- import require$$0 from 'assert';
11
+ import require$$0$1 from 'assert';
12
12
  import require$$2 from 'events';
13
13
  import { createWriteStream, createReadStream } from 'node:fs';
14
14
  import require$$0$4 from 'buffer';
@@ -16,279 +16,6 @@ import require$$0$2 from 'stream';
16
16
  import require$$0$3 from 'util';
17
17
  import { debuglog } from 'node:util';
18
18
 
19
- var signalExit = {exports: {}};
20
-
21
- var signals$1 = {exports: {}};
22
-
23
- var hasRequiredSignals;
24
-
25
- function requireSignals () {
26
- if (hasRequiredSignals) return signals$1.exports;
27
- hasRequiredSignals = 1;
28
- (function (module) {
29
- // This is not the set of all possible signals.
30
- //
31
- // It IS, however, the set of all signals that trigger
32
- // an exit on either Linux or BSD systems. Linux is a
33
- // superset of the signal names supported on BSD, and
34
- // the unknown signals just fail to register, so we can
35
- // catch that easily enough.
36
- //
37
- // Don't bother with SIGKILL. It's uncatchable, which
38
- // means that we can't fire any callbacks anyway.
39
- //
40
- // If a user does happen to register a handler on a non-
41
- // fatal signal like SIGWINCH or something, and then
42
- // exit, it'll end up firing `process.emit('exit')`, so
43
- // the handler will be fired anyway.
44
- //
45
- // SIGBUS, SIGFPE, SIGSEGV and SIGILL, when not raised
46
- // artificially, inherently leave the process in a
47
- // state from which it is not safe to try and enter JS
48
- // listeners.
49
- module.exports = [
50
- 'SIGABRT',
51
- 'SIGALRM',
52
- 'SIGHUP',
53
- 'SIGINT',
54
- 'SIGTERM'
55
- ];
56
-
57
- if (process.platform !== 'win32') {
58
- module.exports.push(
59
- 'SIGVTALRM',
60
- 'SIGXCPU',
61
- 'SIGXFSZ',
62
- 'SIGUSR2',
63
- 'SIGTRAP',
64
- 'SIGSYS',
65
- 'SIGQUIT',
66
- 'SIGIOT'
67
- // should detect profiler and enable/disable accordingly.
68
- // see #21
69
- // 'SIGPROF'
70
- );
71
- }
72
-
73
- if (process.platform === 'linux') {
74
- module.exports.push(
75
- 'SIGIO',
76
- 'SIGPOLL',
77
- 'SIGPWR',
78
- 'SIGSTKFLT',
79
- 'SIGUNUSED'
80
- );
81
- }
82
- } (signals$1));
83
- return signals$1.exports;
84
- }
85
-
86
- // Note: since nyc uses this module to output coverage, any lines
87
- // that are in the direct sync flow of nyc's outputCoverage are
88
- // ignored, since we can never get coverage for them.
89
- // grab a reference to node's real process object right away
90
- var process$1 = commonjsGlobal.process;
91
-
92
- const processOk = function (process) {
93
- return process &&
94
- typeof process === 'object' &&
95
- typeof process.removeListener === 'function' &&
96
- typeof process.emit === 'function' &&
97
- typeof process.reallyExit === 'function' &&
98
- typeof process.listeners === 'function' &&
99
- typeof process.kill === 'function' &&
100
- typeof process.pid === 'number' &&
101
- typeof process.on === 'function'
102
- };
103
-
104
- // some kind of non-node environment, just no-op
105
- /* istanbul ignore if */
106
- if (!processOk(process$1)) {
107
- signalExit.exports = function () {
108
- return function () {}
109
- };
110
- } else {
111
- var assert = require$$0;
112
- var signals = requireSignals();
113
- var isWin$2 = /^win/i.test(process$1.platform);
114
-
115
- var EE = require$$2;
116
- /* istanbul ignore if */
117
- if (typeof EE !== 'function') {
118
- EE = EE.EventEmitter;
119
- }
120
-
121
- var emitter;
122
- if (process$1.__signal_exit_emitter__) {
123
- emitter = process$1.__signal_exit_emitter__;
124
- } else {
125
- emitter = process$1.__signal_exit_emitter__ = new EE();
126
- emitter.count = 0;
127
- emitter.emitted = {};
128
- }
129
-
130
- // Because this emitter is a global, we have to check to see if a
131
- // previous version of this library failed to enable infinite listeners.
132
- // I know what you're about to say. But literally everything about
133
- // signal-exit is a compromise with evil. Get used to it.
134
- if (!emitter.infinite) {
135
- emitter.setMaxListeners(Infinity);
136
- emitter.infinite = true;
137
- }
138
-
139
- signalExit.exports = function (cb, opts) {
140
- /* istanbul ignore if */
141
- if (!processOk(commonjsGlobal.process)) {
142
- return function () {}
143
- }
144
- assert.equal(typeof cb, 'function', 'a callback must be provided for exit handler');
145
-
146
- if (loaded === false) {
147
- load();
148
- }
149
-
150
- var ev = 'exit';
151
- if (opts && opts.alwaysLast) {
152
- ev = 'afterexit';
153
- }
154
-
155
- var remove = function () {
156
- emitter.removeListener(ev, cb);
157
- if (emitter.listeners('exit').length === 0 &&
158
- emitter.listeners('afterexit').length === 0) {
159
- unload();
160
- }
161
- };
162
- emitter.on(ev, cb);
163
-
164
- return remove
165
- };
166
-
167
- var unload = function unload () {
168
- if (!loaded || !processOk(commonjsGlobal.process)) {
169
- return
170
- }
171
- loaded = false;
172
-
173
- signals.forEach(function (sig) {
174
- try {
175
- process$1.removeListener(sig, sigListeners[sig]);
176
- } catch (er) {}
177
- });
178
- process$1.emit = originalProcessEmit;
179
- process$1.reallyExit = originalProcessReallyExit;
180
- emitter.count -= 1;
181
- };
182
- signalExit.exports.unload = unload;
183
-
184
- var emit = function emit (event, code, signal) {
185
- /* istanbul ignore if */
186
- if (emitter.emitted[event]) {
187
- return
188
- }
189
- emitter.emitted[event] = true;
190
- emitter.emit(event, code, signal);
191
- };
192
-
193
- // { <signal>: <listener fn>, ... }
194
- var sigListeners = {};
195
- signals.forEach(function (sig) {
196
- sigListeners[sig] = function listener () {
197
- /* istanbul ignore if */
198
- if (!processOk(commonjsGlobal.process)) {
199
- return
200
- }
201
- // If there are no other listeners, an exit is coming!
202
- // Simplest way: remove us and then re-send the signal.
203
- // We know that this will kill the process, so we can
204
- // safely emit now.
205
- var listeners = process$1.listeners(sig);
206
- if (listeners.length === emitter.count) {
207
- unload();
208
- emit('exit', null, sig);
209
- /* istanbul ignore next */
210
- emit('afterexit', null, sig);
211
- /* istanbul ignore next */
212
- if (isWin$2 && sig === 'SIGHUP') {
213
- // "SIGHUP" throws an `ENOSYS` error on Windows,
214
- // so use a supported signal instead
215
- sig = 'SIGINT';
216
- }
217
- /* istanbul ignore next */
218
- process$1.kill(process$1.pid, sig);
219
- }
220
- };
221
- });
222
-
223
- signalExit.exports.signals = function () {
224
- return signals
225
- };
226
-
227
- var loaded = false;
228
-
229
- var load = function load () {
230
- if (loaded || !processOk(commonjsGlobal.process)) {
231
- return
232
- }
233
- loaded = true;
234
-
235
- // This is the number of onSignalExit's that are in play.
236
- // It's important so that we can count the correct number of
237
- // listeners on signals, and don't wait for the other one to
238
- // handle it instead of us.
239
- emitter.count += 1;
240
-
241
- signals = signals.filter(function (sig) {
242
- try {
243
- process$1.on(sig, sigListeners[sig]);
244
- return true
245
- } catch (er) {
246
- return false
247
- }
248
- });
249
-
250
- process$1.emit = processEmit;
251
- process$1.reallyExit = processReallyExit;
252
- };
253
- signalExit.exports.load = load;
254
-
255
- var originalProcessReallyExit = process$1.reallyExit;
256
- var processReallyExit = function processReallyExit (code) {
257
- /* istanbul ignore if */
258
- if (!processOk(commonjsGlobal.process)) {
259
- return
260
- }
261
- process$1.exitCode = code || /* istanbul ignore next */ 0;
262
- emit('exit', process$1.exitCode, null);
263
- /* istanbul ignore next */
264
- emit('afterexit', process$1.exitCode, null);
265
- /* istanbul ignore next */
266
- originalProcessReallyExit.call(process$1, process$1.exitCode);
267
- };
268
-
269
- var originalProcessEmit = process$1.emit;
270
- var processEmit = function processEmit (ev, arg) {
271
- if (ev === 'exit' && processOk(commonjsGlobal.process)) {
272
- /* istanbul ignore else */
273
- if (arg !== undefined) {
274
- process$1.exitCode = arg;
275
- }
276
- var ret = originalProcessEmit.apply(this, arguments);
277
- /* istanbul ignore next */
278
- emit('exit', process$1.exitCode, null);
279
- /* istanbul ignore next */
280
- emit('afterexit', process$1.exitCode, null);
281
- /* istanbul ignore next */
282
- return ret
283
- } else {
284
- return originalProcessEmit.apply(this, arguments)
285
- }
286
- };
287
- }
288
-
289
- var signalExitExports = signalExit.exports;
290
- var onExit = /*@__PURE__*/getDefaultExportFromCjs(signalExitExports);
291
-
292
19
  var crossSpawn$1 = {exports: {}};
293
20
 
294
21
  var windows;
@@ -739,7 +466,7 @@ const resolveCommand = resolveCommand_1;
739
466
  const escape = _escape;
740
467
  const readShebang = readShebang_1;
741
468
 
742
- const isWin$1 = process.platform === 'win32';
469
+ const isWin$2 = process.platform === 'win32';
743
470
  const isExecutableRegExp = /\.(?:com|exe)$/i;
744
471
  const isCmdShimRegExp = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
745
472
 
@@ -759,7 +486,7 @@ function detectShebang(parsed) {
759
486
  }
760
487
 
761
488
  function parseNonShell(parsed) {
762
- if (!isWin$1) {
489
+ if (!isWin$2) {
763
490
  return parsed;
764
491
  }
765
492
 
@@ -824,7 +551,7 @@ function parse$1(command, args, options) {
824
551
 
825
552
  var parse_1 = parse$1;
826
553
 
827
- const isWin = process.platform === 'win32';
554
+ const isWin$1 = process.platform === 'win32';
828
555
 
829
556
  function notFoundError(original, syscall) {
830
557
  return Object.assign(new Error(`${syscall} ${original.command} ENOENT`), {
@@ -837,7 +564,7 @@ function notFoundError(original, syscall) {
837
564
  }
838
565
 
839
566
  function hookChildProcess(cp, parsed) {
840
- if (!isWin) {
567
+ if (!isWin$1) {
841
568
  return;
842
569
  }
843
570
 
@@ -860,7 +587,7 @@ function hookChildProcess(cp, parsed) {
860
587
  }
861
588
 
862
589
  function verifyENOENT(status, parsed) {
863
- if (isWin && status === 1 && !parsed.file) {
590
+ if (isWin$1 && status === 1 && !parsed.file) {
864
591
  return notFoundError(parsed.original, 'spawn');
865
592
  }
866
593
 
@@ -868,7 +595,7 @@ function verifyENOENT(status, parsed) {
868
595
  }
869
596
 
870
597
  function verifyENOENTSync(status, parsed) {
871
- if (isWin && status === 1 && !parsed.file) {
598
+ if (isWin$1 && status === 1 && !parsed.file) {
872
599
  return notFoundError(parsed.original, 'spawnSync');
873
600
  }
874
601
 
@@ -882,7 +609,7 @@ var enoent$1 = {
882
609
  notFoundError,
883
610
  };
884
611
 
885
- const cp = require$$0$1;
612
+ const cp = require$$0;
886
613
  const parse = parse_1;
887
614
  const enoent = enoent$1;
888
615
 
@@ -1486,115 +1213,388 @@ const getErrorPrefix = ({timedOut, timeout, errorCode, signal, signalDescription
1486
1213
  return `timed out after ${timeout} milliseconds`;
1487
1214
  }
1488
1215
 
1489
- if (isCanceled) {
1490
- return 'was canceled';
1491
- }
1216
+ if (isCanceled) {
1217
+ return 'was canceled';
1218
+ }
1219
+
1220
+ if (errorCode !== undefined) {
1221
+ return `failed with ${errorCode}`;
1222
+ }
1223
+
1224
+ if (signal !== undefined) {
1225
+ return `was killed with ${signal} (${signalDescription})`;
1226
+ }
1227
+
1228
+ if (exitCode !== undefined) {
1229
+ return `failed with exit code ${exitCode}`;
1230
+ }
1231
+
1232
+ return 'failed';
1233
+ };
1234
+
1235
+ const makeError = ({
1236
+ stdout,
1237
+ stderr,
1238
+ all,
1239
+ error,
1240
+ signal,
1241
+ exitCode,
1242
+ command,
1243
+ escapedCommand,
1244
+ timedOut,
1245
+ isCanceled,
1246
+ killed,
1247
+ parsed: {options: {timeout}},
1248
+ }) => {
1249
+ // `signal` and `exitCode` emitted on `spawned.on('exit')` event can be `null`.
1250
+ // We normalize them to `undefined`
1251
+ exitCode = exitCode === null ? undefined : exitCode;
1252
+ signal = signal === null ? undefined : signal;
1253
+ const signalDescription = signal === undefined ? undefined : signalsByName[signal].description;
1254
+
1255
+ const errorCode = error && error.code;
1256
+
1257
+ const prefix = getErrorPrefix({timedOut, timeout, errorCode, signal, signalDescription, exitCode, isCanceled});
1258
+ const execaMessage = `Command ${prefix}: ${command}`;
1259
+ const isError = Object.prototype.toString.call(error) === '[object Error]';
1260
+ const shortMessage = isError ? `${execaMessage}\n${error.message}` : execaMessage;
1261
+ const message = [shortMessage, stderr, stdout].filter(Boolean).join('\n');
1262
+
1263
+ if (isError) {
1264
+ error.originalMessage = error.message;
1265
+ error.message = message;
1266
+ } else {
1267
+ error = new Error(message);
1268
+ }
1269
+
1270
+ error.shortMessage = shortMessage;
1271
+ error.command = command;
1272
+ error.escapedCommand = escapedCommand;
1273
+ error.exitCode = exitCode;
1274
+ error.signal = signal;
1275
+ error.signalDescription = signalDescription;
1276
+ error.stdout = stdout;
1277
+ error.stderr = stderr;
1278
+
1279
+ if (all !== undefined) {
1280
+ error.all = all;
1281
+ }
1282
+
1283
+ if ('bufferedData' in error) {
1284
+ delete error.bufferedData;
1285
+ }
1286
+
1287
+ error.failed = true;
1288
+ error.timedOut = Boolean(timedOut);
1289
+ error.isCanceled = isCanceled;
1290
+ error.killed = killed && !timedOut;
1291
+
1292
+ return error;
1293
+ };
1294
+
1295
+ const aliases = ['stdin', 'stdout', 'stderr'];
1296
+
1297
+ const hasAlias = options => aliases.some(alias => options[alias] !== undefined);
1298
+
1299
+ const normalizeStdio = options => {
1300
+ if (!options) {
1301
+ return;
1302
+ }
1303
+
1304
+ const {stdio} = options;
1305
+
1306
+ if (stdio === undefined) {
1307
+ return aliases.map(alias => options[alias]);
1308
+ }
1309
+
1310
+ if (hasAlias(options)) {
1311
+ throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${aliases.map(alias => `\`${alias}\``).join(', ')}`);
1312
+ }
1313
+
1314
+ if (typeof stdio === 'string') {
1315
+ return stdio;
1316
+ }
1317
+
1318
+ if (!Array.isArray(stdio)) {
1319
+ throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof stdio}\``);
1320
+ }
1321
+
1322
+ const length = Math.max(stdio.length, aliases.length);
1323
+ return Array.from({length}, (value, index) => stdio[index]);
1324
+ };
1325
+
1326
+ var signalExit$1 = {exports: {}};
1327
+
1328
+ var signals$1 = {exports: {}};
1329
+
1330
+ var hasRequiredSignals;
1331
+
1332
+ function requireSignals () {
1333
+ if (hasRequiredSignals) return signals$1.exports;
1334
+ hasRequiredSignals = 1;
1335
+ (function (module) {
1336
+ // This is not the set of all possible signals.
1337
+ //
1338
+ // It IS, however, the set of all signals that trigger
1339
+ // an exit on either Linux or BSD systems. Linux is a
1340
+ // superset of the signal names supported on BSD, and
1341
+ // the unknown signals just fail to register, so we can
1342
+ // catch that easily enough.
1343
+ //
1344
+ // Don't bother with SIGKILL. It's uncatchable, which
1345
+ // means that we can't fire any callbacks anyway.
1346
+ //
1347
+ // If a user does happen to register a handler on a non-
1348
+ // fatal signal like SIGWINCH or something, and then
1349
+ // exit, it'll end up firing `process.emit('exit')`, so
1350
+ // the handler will be fired anyway.
1351
+ //
1352
+ // SIGBUS, SIGFPE, SIGSEGV and SIGILL, when not raised
1353
+ // artificially, inherently leave the process in a
1354
+ // state from which it is not safe to try and enter JS
1355
+ // listeners.
1356
+ module.exports = [
1357
+ 'SIGABRT',
1358
+ 'SIGALRM',
1359
+ 'SIGHUP',
1360
+ 'SIGINT',
1361
+ 'SIGTERM'
1362
+ ];
1363
+
1364
+ if (process.platform !== 'win32') {
1365
+ module.exports.push(
1366
+ 'SIGVTALRM',
1367
+ 'SIGXCPU',
1368
+ 'SIGXFSZ',
1369
+ 'SIGUSR2',
1370
+ 'SIGTRAP',
1371
+ 'SIGSYS',
1372
+ 'SIGQUIT',
1373
+ 'SIGIOT'
1374
+ // should detect profiler and enable/disable accordingly.
1375
+ // see #21
1376
+ // 'SIGPROF'
1377
+ );
1378
+ }
1379
+
1380
+ if (process.platform === 'linux') {
1381
+ module.exports.push(
1382
+ 'SIGIO',
1383
+ 'SIGPOLL',
1384
+ 'SIGPWR',
1385
+ 'SIGSTKFLT',
1386
+ 'SIGUNUSED'
1387
+ );
1388
+ }
1389
+ } (signals$1));
1390
+ return signals$1.exports;
1391
+ }
1392
+
1393
+ // Note: since nyc uses this module to output coverage, any lines
1394
+ // that are in the direct sync flow of nyc's outputCoverage are
1395
+ // ignored, since we can never get coverage for them.
1396
+ // grab a reference to node's real process object right away
1397
+ var process$1 = commonjsGlobal.process;
1398
+
1399
+ const processOk = function (process) {
1400
+ return process &&
1401
+ typeof process === 'object' &&
1402
+ typeof process.removeListener === 'function' &&
1403
+ typeof process.emit === 'function' &&
1404
+ typeof process.reallyExit === 'function' &&
1405
+ typeof process.listeners === 'function' &&
1406
+ typeof process.kill === 'function' &&
1407
+ typeof process.pid === 'number' &&
1408
+ typeof process.on === 'function'
1409
+ };
1492
1410
 
1493
- if (errorCode !== undefined) {
1494
- return `failed with ${errorCode}`;
1495
- }
1411
+ // some kind of non-node environment, just no-op
1412
+ /* istanbul ignore if */
1413
+ if (!processOk(process$1)) {
1414
+ signalExit$1.exports = function () {
1415
+ return function () {}
1416
+ };
1417
+ } else {
1418
+ var assert = require$$0$1;
1419
+ var signals = requireSignals();
1420
+ var isWin = /^win/i.test(process$1.platform);
1496
1421
 
1497
- if (signal !== undefined) {
1498
- return `was killed with ${signal} (${signalDescription})`;
1499
- }
1422
+ var EE = require$$2;
1423
+ /* istanbul ignore if */
1424
+ if (typeof EE !== 'function') {
1425
+ EE = EE.EventEmitter;
1426
+ }
1500
1427
 
1501
- if (exitCode !== undefined) {
1502
- return `failed with exit code ${exitCode}`;
1503
- }
1428
+ var emitter;
1429
+ if (process$1.__signal_exit_emitter__) {
1430
+ emitter = process$1.__signal_exit_emitter__;
1431
+ } else {
1432
+ emitter = process$1.__signal_exit_emitter__ = new EE();
1433
+ emitter.count = 0;
1434
+ emitter.emitted = {};
1435
+ }
1504
1436
 
1505
- return 'failed';
1506
- };
1437
+ // Because this emitter is a global, we have to check to see if a
1438
+ // previous version of this library failed to enable infinite listeners.
1439
+ // I know what you're about to say. But literally everything about
1440
+ // signal-exit is a compromise with evil. Get used to it.
1441
+ if (!emitter.infinite) {
1442
+ emitter.setMaxListeners(Infinity);
1443
+ emitter.infinite = true;
1444
+ }
1507
1445
 
1508
- const makeError = ({
1509
- stdout,
1510
- stderr,
1511
- all,
1512
- error,
1513
- signal,
1514
- exitCode,
1515
- command,
1516
- escapedCommand,
1517
- timedOut,
1518
- isCanceled,
1519
- killed,
1520
- parsed: {options: {timeout}},
1521
- }) => {
1522
- // `signal` and `exitCode` emitted on `spawned.on('exit')` event can be `null`.
1523
- // We normalize them to `undefined`
1524
- exitCode = exitCode === null ? undefined : exitCode;
1525
- signal = signal === null ? undefined : signal;
1526
- const signalDescription = signal === undefined ? undefined : signalsByName[signal].description;
1446
+ signalExit$1.exports = function (cb, opts) {
1447
+ /* istanbul ignore if */
1448
+ if (!processOk(commonjsGlobal.process)) {
1449
+ return function () {}
1450
+ }
1451
+ assert.equal(typeof cb, 'function', 'a callback must be provided for exit handler');
1527
1452
 
1528
- const errorCode = error && error.code;
1453
+ if (loaded === false) {
1454
+ load();
1455
+ }
1529
1456
 
1530
- const prefix = getErrorPrefix({timedOut, timeout, errorCode, signal, signalDescription, exitCode, isCanceled});
1531
- const execaMessage = `Command ${prefix}: ${command}`;
1532
- const isError = Object.prototype.toString.call(error) === '[object Error]';
1533
- const shortMessage = isError ? `${execaMessage}\n${error.message}` : execaMessage;
1534
- const message = [shortMessage, stderr, stdout].filter(Boolean).join('\n');
1457
+ var ev = 'exit';
1458
+ if (opts && opts.alwaysLast) {
1459
+ ev = 'afterexit';
1460
+ }
1535
1461
 
1536
- if (isError) {
1537
- error.originalMessage = error.message;
1538
- error.message = message;
1539
- } else {
1540
- error = new Error(message);
1541
- }
1462
+ var remove = function () {
1463
+ emitter.removeListener(ev, cb);
1464
+ if (emitter.listeners('exit').length === 0 &&
1465
+ emitter.listeners('afterexit').length === 0) {
1466
+ unload();
1467
+ }
1468
+ };
1469
+ emitter.on(ev, cb);
1542
1470
 
1543
- error.shortMessage = shortMessage;
1544
- error.command = command;
1545
- error.escapedCommand = escapedCommand;
1546
- error.exitCode = exitCode;
1547
- error.signal = signal;
1548
- error.signalDescription = signalDescription;
1549
- error.stdout = stdout;
1550
- error.stderr = stderr;
1471
+ return remove
1472
+ };
1551
1473
 
1552
- if (all !== undefined) {
1553
- error.all = all;
1554
- }
1474
+ var unload = function unload () {
1475
+ if (!loaded || !processOk(commonjsGlobal.process)) {
1476
+ return
1477
+ }
1478
+ loaded = false;
1555
1479
 
1556
- if ('bufferedData' in error) {
1557
- delete error.bufferedData;
1558
- }
1480
+ signals.forEach(function (sig) {
1481
+ try {
1482
+ process$1.removeListener(sig, sigListeners[sig]);
1483
+ } catch (er) {}
1484
+ });
1485
+ process$1.emit = originalProcessEmit;
1486
+ process$1.reallyExit = originalProcessReallyExit;
1487
+ emitter.count -= 1;
1488
+ };
1489
+ signalExit$1.exports.unload = unload;
1559
1490
 
1560
- error.failed = true;
1561
- error.timedOut = Boolean(timedOut);
1562
- error.isCanceled = isCanceled;
1563
- error.killed = killed && !timedOut;
1491
+ var emit = function emit (event, code, signal) {
1492
+ /* istanbul ignore if */
1493
+ if (emitter.emitted[event]) {
1494
+ return
1495
+ }
1496
+ emitter.emitted[event] = true;
1497
+ emitter.emit(event, code, signal);
1498
+ };
1564
1499
 
1565
- return error;
1566
- };
1500
+ // { <signal>: <listener fn>, ... }
1501
+ var sigListeners = {};
1502
+ signals.forEach(function (sig) {
1503
+ sigListeners[sig] = function listener () {
1504
+ /* istanbul ignore if */
1505
+ if (!processOk(commonjsGlobal.process)) {
1506
+ return
1507
+ }
1508
+ // If there are no other listeners, an exit is coming!
1509
+ // Simplest way: remove us and then re-send the signal.
1510
+ // We know that this will kill the process, so we can
1511
+ // safely emit now.
1512
+ var listeners = process$1.listeners(sig);
1513
+ if (listeners.length === emitter.count) {
1514
+ unload();
1515
+ emit('exit', null, sig);
1516
+ /* istanbul ignore next */
1517
+ emit('afterexit', null, sig);
1518
+ /* istanbul ignore next */
1519
+ if (isWin && sig === 'SIGHUP') {
1520
+ // "SIGHUP" throws an `ENOSYS` error on Windows,
1521
+ // so use a supported signal instead
1522
+ sig = 'SIGINT';
1523
+ }
1524
+ /* istanbul ignore next */
1525
+ process$1.kill(process$1.pid, sig);
1526
+ }
1527
+ };
1528
+ });
1567
1529
 
1568
- const aliases = ['stdin', 'stdout', 'stderr'];
1530
+ signalExit$1.exports.signals = function () {
1531
+ return signals
1532
+ };
1569
1533
 
1570
- const hasAlias = options => aliases.some(alias => options[alias] !== undefined);
1534
+ var loaded = false;
1571
1535
 
1572
- const normalizeStdio = options => {
1573
- if (!options) {
1574
- return;
1575
- }
1536
+ var load = function load () {
1537
+ if (loaded || !processOk(commonjsGlobal.process)) {
1538
+ return
1539
+ }
1540
+ loaded = true;
1576
1541
 
1577
- const {stdio} = options;
1542
+ // This is the number of onSignalExit's that are in play.
1543
+ // It's important so that we can count the correct number of
1544
+ // listeners on signals, and don't wait for the other one to
1545
+ // handle it instead of us.
1546
+ emitter.count += 1;
1578
1547
 
1579
- if (stdio === undefined) {
1580
- return aliases.map(alias => options[alias]);
1581
- }
1548
+ signals = signals.filter(function (sig) {
1549
+ try {
1550
+ process$1.on(sig, sigListeners[sig]);
1551
+ return true
1552
+ } catch (er) {
1553
+ return false
1554
+ }
1555
+ });
1582
1556
 
1583
- if (hasAlias(options)) {
1584
- throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${aliases.map(alias => `\`${alias}\``).join(', ')}`);
1585
- }
1557
+ process$1.emit = processEmit;
1558
+ process$1.reallyExit = processReallyExit;
1559
+ };
1560
+ signalExit$1.exports.load = load;
1586
1561
 
1587
- if (typeof stdio === 'string') {
1588
- return stdio;
1589
- }
1562
+ var originalProcessReallyExit = process$1.reallyExit;
1563
+ var processReallyExit = function processReallyExit (code) {
1564
+ /* istanbul ignore if */
1565
+ if (!processOk(commonjsGlobal.process)) {
1566
+ return
1567
+ }
1568
+ process$1.exitCode = code || /* istanbul ignore next */ 0;
1569
+ emit('exit', process$1.exitCode, null);
1570
+ /* istanbul ignore next */
1571
+ emit('afterexit', process$1.exitCode, null);
1572
+ /* istanbul ignore next */
1573
+ originalProcessReallyExit.call(process$1, process$1.exitCode);
1574
+ };
1590
1575
 
1591
- if (!Array.isArray(stdio)) {
1592
- throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof stdio}\``);
1593
- }
1576
+ var originalProcessEmit = process$1.emit;
1577
+ var processEmit = function processEmit (ev, arg) {
1578
+ if (ev === 'exit' && processOk(commonjsGlobal.process)) {
1579
+ /* istanbul ignore else */
1580
+ if (arg !== undefined) {
1581
+ process$1.exitCode = arg;
1582
+ }
1583
+ var ret = originalProcessEmit.apply(this, arguments);
1584
+ /* istanbul ignore next */
1585
+ emit('exit', process$1.exitCode, null);
1586
+ /* istanbul ignore next */
1587
+ emit('afterexit', process$1.exitCode, null);
1588
+ /* istanbul ignore next */
1589
+ return ret
1590
+ } else {
1591
+ return originalProcessEmit.apply(this, arguments)
1592
+ }
1593
+ };
1594
+ }
1594
1595
 
1595
- const length = Math.max(stdio.length, aliases.length);
1596
- return Array.from({length}, (value, index) => stdio[index]);
1597
- };
1596
+ var signalExitExports = signalExit$1.exports;
1597
+ var signalExit = /*@__PURE__*/getDefaultExportFromCjs(signalExitExports);
1598
1598
 
1599
1599
  const DEFAULT_FORCE_KILL_TIMEOUT = 1000 * 5;
1600
1600
 
@@ -1687,7 +1687,7 @@ const setExitHandler = async (spawned, {cleanup, detached}, timedPromise) => {
1687
1687
  return timedPromise;
1688
1688
  }
1689
1689
 
1690
- const removeExitHandler = onExit(() => {
1690
+ const removeExitHandler = signalExit(() => {
1691
1691
  spawned.kill();
1692
1692
  });
1693
1693
 
@@ -2233,4 +2233,4 @@ function execa(file, args, options) {
2233
2233
  return spawned;
2234
2234
  }
2235
2235
 
2236
- export { crossSpawnExports as c, execa as e, getStreamExports as g, mergeStream as m, onExit as o, pathKeyExports as p, signalExitExports as s };
2236
+ export { signalExit as a, crossSpawnExports as c, execa as e, getStreamExports as g, mergeStream as m, pathKeyExports as p, signalExitExports as s };