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.
- package/dist/_commonjsHelpers-c9e3b764.js +1 -0
- package/dist/cli.js +10 -9
- package/dist/constants-0211a379.js +34 -0
- package/dist/diff-18d4a7eb.js +4750 -0
- package/dist/entry.js +94 -33
- package/dist/externalize-2f63779d.js +1 -0
- package/dist/global-5d1fb309.js +21 -0
- package/dist/index-26cb6e63.js +1644 -0
- package/dist/index-354a6abd.js +40 -0
- package/dist/index-4cd25949.js +782 -0
- package/dist/index-720a83c6.js +396 -0
- package/dist/index-7975be53.js +331 -0
- package/dist/index-7f7acd60.js +8548 -0
- package/dist/index-e909c175.js +63 -0
- package/dist/index-fa899e66.js +5708 -0
- package/dist/index.d.ts +142 -27
- package/dist/index.js +4 -3
- package/dist/jest-mock-30625866.js +1 -0
- package/dist/magic-string.es-94000aea.js +1361 -0
- package/dist/node.d.ts +111 -4
- package/dist/node.js +9 -8
- package/dist/rpc-8c7cc374.js +1 -0
- package/dist/setup-5aaf533e.js +4365 -0
- package/dist/vi-aec007e7.js +3461 -0
- package/dist/worker.js +11 -7
- package/package.json +9 -9
- package/dist/constants-868b9a2e.js +0 -33
- package/dist/diff-be830986.js +0 -4751
- package/dist/global-0254dd68.js +0 -20
- package/dist/index-06712022.js +0 -39
- package/dist/index-42a3a132.js +0 -366
- package/dist/index-42d44ee5.js +0 -1643
- package/dist/index-93dcb598.js +0 -5707
- package/dist/index-a73f33e0.js +0 -62
- package/dist/index-cb02ee01.js +0 -330
- package/dist/index-cce5de77.js +0 -781
- package/dist/index-d30b5ed0.js +0 -8579
- package/dist/magic-string.es-98a8bfa0.js +0 -1360
- package/dist/setup-6e09a65a.js +0 -4364
- package/dist/vi-fe26a646.js +0 -3460
package/dist/index-cce5de77.js
DELETED
|
@@ -1,781 +0,0 @@
|
|
|
1
|
-
import childProcess from 'child_process';
|
|
2
|
-
import path$3 from 'path';
|
|
3
|
-
import { c as commonjsGlobal } from './_commonjsHelpers-c9e3b764.js';
|
|
4
|
-
import fs$3 from 'fs';
|
|
5
|
-
import require$$0$2 from 'buffer';
|
|
6
|
-
import require$$0 from 'stream';
|
|
7
|
-
import require$$0$1 from 'util';
|
|
8
|
-
|
|
9
|
-
var crossSpawn$1 = {exports: {}};
|
|
10
|
-
|
|
11
|
-
var windows = isexe$3;
|
|
12
|
-
isexe$3.sync = sync$2;
|
|
13
|
-
|
|
14
|
-
var fs$2 = fs$3;
|
|
15
|
-
|
|
16
|
-
function checkPathExt (path, options) {
|
|
17
|
-
var pathext = options.pathExt !== undefined ?
|
|
18
|
-
options.pathExt : process.env.PATHEXT;
|
|
19
|
-
|
|
20
|
-
if (!pathext) {
|
|
21
|
-
return true
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
pathext = pathext.split(';');
|
|
25
|
-
if (pathext.indexOf('') !== -1) {
|
|
26
|
-
return true
|
|
27
|
-
}
|
|
28
|
-
for (var i = 0; i < pathext.length; i++) {
|
|
29
|
-
var p = pathext[i].toLowerCase();
|
|
30
|
-
if (p && path.substr(-p.length).toLowerCase() === p) {
|
|
31
|
-
return true
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
return false
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function checkStat$1 (stat, path, options) {
|
|
38
|
-
if (!stat.isSymbolicLink() && !stat.isFile()) {
|
|
39
|
-
return false
|
|
40
|
-
}
|
|
41
|
-
return checkPathExt(path, options)
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function isexe$3 (path, options, cb) {
|
|
45
|
-
fs$2.stat(path, function (er, stat) {
|
|
46
|
-
cb(er, er ? false : checkStat$1(stat, path, options));
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function sync$2 (path, options) {
|
|
51
|
-
return checkStat$1(fs$2.statSync(path), path, options)
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
var mode = isexe$2;
|
|
55
|
-
isexe$2.sync = sync$1;
|
|
56
|
-
|
|
57
|
-
var fs$1 = fs$3;
|
|
58
|
-
|
|
59
|
-
function isexe$2 (path, options, cb) {
|
|
60
|
-
fs$1.stat(path, function (er, stat) {
|
|
61
|
-
cb(er, er ? false : checkStat(stat, options));
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
function sync$1 (path, options) {
|
|
66
|
-
return checkStat(fs$1.statSync(path), options)
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
function checkStat (stat, options) {
|
|
70
|
-
return stat.isFile() && checkMode(stat, options)
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
function checkMode (stat, options) {
|
|
74
|
-
var mod = stat.mode;
|
|
75
|
-
var uid = stat.uid;
|
|
76
|
-
var gid = stat.gid;
|
|
77
|
-
|
|
78
|
-
var myUid = options.uid !== undefined ?
|
|
79
|
-
options.uid : process.getuid && process.getuid();
|
|
80
|
-
var myGid = options.gid !== undefined ?
|
|
81
|
-
options.gid : process.getgid && process.getgid();
|
|
82
|
-
|
|
83
|
-
var u = parseInt('100', 8);
|
|
84
|
-
var g = parseInt('010', 8);
|
|
85
|
-
var o = parseInt('001', 8);
|
|
86
|
-
var ug = u | g;
|
|
87
|
-
|
|
88
|
-
var ret = (mod & o) ||
|
|
89
|
-
(mod & g) && gid === myGid ||
|
|
90
|
-
(mod & u) && uid === myUid ||
|
|
91
|
-
(mod & ug) && myUid === 0;
|
|
92
|
-
|
|
93
|
-
return ret
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
var core;
|
|
97
|
-
if (process.platform === 'win32' || commonjsGlobal.TESTING_WINDOWS) {
|
|
98
|
-
core = windows;
|
|
99
|
-
} else {
|
|
100
|
-
core = mode;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
var isexe_1 = isexe$1;
|
|
104
|
-
isexe$1.sync = sync;
|
|
105
|
-
|
|
106
|
-
function isexe$1 (path, options, cb) {
|
|
107
|
-
if (typeof options === 'function') {
|
|
108
|
-
cb = options;
|
|
109
|
-
options = {};
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
if (!cb) {
|
|
113
|
-
if (typeof Promise !== 'function') {
|
|
114
|
-
throw new TypeError('callback not provided')
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
return new Promise(function (resolve, reject) {
|
|
118
|
-
isexe$1(path, options || {}, function (er, is) {
|
|
119
|
-
if (er) {
|
|
120
|
-
reject(er);
|
|
121
|
-
} else {
|
|
122
|
-
resolve(is);
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
|
-
})
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
core(path, options || {}, function (er, is) {
|
|
129
|
-
// ignore EACCES because that just means we aren't allowed to run it
|
|
130
|
-
if (er) {
|
|
131
|
-
if (er.code === 'EACCES' || options && options.ignoreErrors) {
|
|
132
|
-
er = null;
|
|
133
|
-
is = false;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
cb(er, is);
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
function sync (path, options) {
|
|
141
|
-
// my kingdom for a filtered catch
|
|
142
|
-
try {
|
|
143
|
-
return core.sync(path, options || {})
|
|
144
|
-
} catch (er) {
|
|
145
|
-
if (options && options.ignoreErrors || er.code === 'EACCES') {
|
|
146
|
-
return false
|
|
147
|
-
} else {
|
|
148
|
-
throw er
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
const isWindows = process.platform === 'win32' ||
|
|
154
|
-
process.env.OSTYPE === 'cygwin' ||
|
|
155
|
-
process.env.OSTYPE === 'msys';
|
|
156
|
-
|
|
157
|
-
const path$2 = path$3;
|
|
158
|
-
const COLON = isWindows ? ';' : ':';
|
|
159
|
-
const isexe = isexe_1;
|
|
160
|
-
|
|
161
|
-
const getNotFoundError = (cmd) =>
|
|
162
|
-
Object.assign(new Error(`not found: ${cmd}`), { code: 'ENOENT' });
|
|
163
|
-
|
|
164
|
-
const getPathInfo = (cmd, opt) => {
|
|
165
|
-
const colon = opt.colon || COLON;
|
|
166
|
-
|
|
167
|
-
// If it has a slash, then we don't bother searching the pathenv.
|
|
168
|
-
// just check the file itself, and that's it.
|
|
169
|
-
const pathEnv = cmd.match(/\//) || isWindows && cmd.match(/\\/) ? ['']
|
|
170
|
-
: (
|
|
171
|
-
[
|
|
172
|
-
// windows always checks the cwd first
|
|
173
|
-
...(isWindows ? [process.cwd()] : []),
|
|
174
|
-
...(opt.path || process.env.PATH ||
|
|
175
|
-
/* istanbul ignore next: very unusual */ '').split(colon),
|
|
176
|
-
]
|
|
177
|
-
);
|
|
178
|
-
const pathExtExe = isWindows
|
|
179
|
-
? opt.pathExt || process.env.PATHEXT || '.EXE;.CMD;.BAT;.COM'
|
|
180
|
-
: '';
|
|
181
|
-
const pathExt = isWindows ? pathExtExe.split(colon) : [''];
|
|
182
|
-
|
|
183
|
-
if (isWindows) {
|
|
184
|
-
if (cmd.indexOf('.') !== -1 && pathExt[0] !== '')
|
|
185
|
-
pathExt.unshift('');
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
return {
|
|
189
|
-
pathEnv,
|
|
190
|
-
pathExt,
|
|
191
|
-
pathExtExe,
|
|
192
|
-
}
|
|
193
|
-
};
|
|
194
|
-
|
|
195
|
-
const which$1 = (cmd, opt, cb) => {
|
|
196
|
-
if (typeof opt === 'function') {
|
|
197
|
-
cb = opt;
|
|
198
|
-
opt = {};
|
|
199
|
-
}
|
|
200
|
-
if (!opt)
|
|
201
|
-
opt = {};
|
|
202
|
-
|
|
203
|
-
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
|
|
204
|
-
const found = [];
|
|
205
|
-
|
|
206
|
-
const step = i => new Promise((resolve, reject) => {
|
|
207
|
-
if (i === pathEnv.length)
|
|
208
|
-
return opt.all && found.length ? resolve(found)
|
|
209
|
-
: reject(getNotFoundError(cmd))
|
|
210
|
-
|
|
211
|
-
const ppRaw = pathEnv[i];
|
|
212
|
-
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
213
|
-
|
|
214
|
-
const pCmd = path$2.join(pathPart, cmd);
|
|
215
|
-
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd
|
|
216
|
-
: pCmd;
|
|
217
|
-
|
|
218
|
-
resolve(subStep(p, i, 0));
|
|
219
|
-
});
|
|
220
|
-
|
|
221
|
-
const subStep = (p, i, ii) => new Promise((resolve, reject) => {
|
|
222
|
-
if (ii === pathExt.length)
|
|
223
|
-
return resolve(step(i + 1))
|
|
224
|
-
const ext = pathExt[ii];
|
|
225
|
-
isexe(p + ext, { pathExt: pathExtExe }, (er, is) => {
|
|
226
|
-
if (!er && is) {
|
|
227
|
-
if (opt.all)
|
|
228
|
-
found.push(p + ext);
|
|
229
|
-
else
|
|
230
|
-
return resolve(p + ext)
|
|
231
|
-
}
|
|
232
|
-
return resolve(subStep(p, i, ii + 1))
|
|
233
|
-
});
|
|
234
|
-
});
|
|
235
|
-
|
|
236
|
-
return cb ? step(0).then(res => cb(null, res), cb) : step(0)
|
|
237
|
-
};
|
|
238
|
-
|
|
239
|
-
const whichSync = (cmd, opt) => {
|
|
240
|
-
opt = opt || {};
|
|
241
|
-
|
|
242
|
-
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
|
|
243
|
-
const found = [];
|
|
244
|
-
|
|
245
|
-
for (let i = 0; i < pathEnv.length; i ++) {
|
|
246
|
-
const ppRaw = pathEnv[i];
|
|
247
|
-
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
248
|
-
|
|
249
|
-
const pCmd = path$2.join(pathPart, cmd);
|
|
250
|
-
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd
|
|
251
|
-
: pCmd;
|
|
252
|
-
|
|
253
|
-
for (let j = 0; j < pathExt.length; j ++) {
|
|
254
|
-
const cur = p + pathExt[j];
|
|
255
|
-
try {
|
|
256
|
-
const is = isexe.sync(cur, { pathExt: pathExtExe });
|
|
257
|
-
if (is) {
|
|
258
|
-
if (opt.all)
|
|
259
|
-
found.push(cur);
|
|
260
|
-
else
|
|
261
|
-
return cur
|
|
262
|
-
}
|
|
263
|
-
} catch (ex) {}
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
if (opt.all && found.length)
|
|
268
|
-
return found
|
|
269
|
-
|
|
270
|
-
if (opt.nothrow)
|
|
271
|
-
return null
|
|
272
|
-
|
|
273
|
-
throw getNotFoundError(cmd)
|
|
274
|
-
};
|
|
275
|
-
|
|
276
|
-
var which_1 = which$1;
|
|
277
|
-
which$1.sync = whichSync;
|
|
278
|
-
|
|
279
|
-
var pathKey$1 = {exports: {}};
|
|
280
|
-
|
|
281
|
-
const pathKey = (options = {}) => {
|
|
282
|
-
const environment = options.env || process.env;
|
|
283
|
-
const platform = options.platform || process.platform;
|
|
284
|
-
|
|
285
|
-
if (platform !== 'win32') {
|
|
286
|
-
return 'PATH';
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
return Object.keys(environment).reverse().find(key => key.toUpperCase() === 'PATH') || 'Path';
|
|
290
|
-
};
|
|
291
|
-
|
|
292
|
-
pathKey$1.exports = pathKey;
|
|
293
|
-
// TODO: Remove this for the next major release
|
|
294
|
-
pathKey$1.exports.default = pathKey;
|
|
295
|
-
|
|
296
|
-
const path$1 = path$3;
|
|
297
|
-
const which = which_1;
|
|
298
|
-
const getPathKey = pathKey$1.exports;
|
|
299
|
-
|
|
300
|
-
function resolveCommandAttempt(parsed, withoutPathExt) {
|
|
301
|
-
const env = parsed.options.env || process.env;
|
|
302
|
-
const cwd = process.cwd();
|
|
303
|
-
const hasCustomCwd = parsed.options.cwd != null;
|
|
304
|
-
// Worker threads do not have process.chdir()
|
|
305
|
-
const shouldSwitchCwd = hasCustomCwd && process.chdir !== undefined && !process.chdir.disabled;
|
|
306
|
-
|
|
307
|
-
// If a custom `cwd` was specified, we need to change the process cwd
|
|
308
|
-
// because `which` will do stat calls but does not support a custom cwd
|
|
309
|
-
if (shouldSwitchCwd) {
|
|
310
|
-
try {
|
|
311
|
-
process.chdir(parsed.options.cwd);
|
|
312
|
-
} catch (err) {
|
|
313
|
-
/* Empty */
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
let resolved;
|
|
318
|
-
|
|
319
|
-
try {
|
|
320
|
-
resolved = which.sync(parsed.command, {
|
|
321
|
-
path: env[getPathKey({ env })],
|
|
322
|
-
pathExt: withoutPathExt ? path$1.delimiter : undefined,
|
|
323
|
-
});
|
|
324
|
-
} catch (e) {
|
|
325
|
-
/* Empty */
|
|
326
|
-
} finally {
|
|
327
|
-
if (shouldSwitchCwd) {
|
|
328
|
-
process.chdir(cwd);
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
// If we successfully resolved, ensure that an absolute path is returned
|
|
333
|
-
// Note that when a custom `cwd` was used, we need to resolve to an absolute path based on it
|
|
334
|
-
if (resolved) {
|
|
335
|
-
resolved = path$1.resolve(hasCustomCwd ? parsed.options.cwd : '', resolved);
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
return resolved;
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
function resolveCommand$1(parsed) {
|
|
342
|
-
return resolveCommandAttempt(parsed) || resolveCommandAttempt(parsed, true);
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
var resolveCommand_1 = resolveCommand$1;
|
|
346
|
-
|
|
347
|
-
var _escape = {};
|
|
348
|
-
|
|
349
|
-
// See http://www.robvanderwoude.com/escapechars.php
|
|
350
|
-
const metaCharsRegExp = /([()\][%!^"`<>&|;, *?])/g;
|
|
351
|
-
|
|
352
|
-
function escapeCommand(arg) {
|
|
353
|
-
// Escape meta chars
|
|
354
|
-
arg = arg.replace(metaCharsRegExp, '^$1');
|
|
355
|
-
|
|
356
|
-
return arg;
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
function escapeArgument(arg, doubleEscapeMetaChars) {
|
|
360
|
-
// Convert to string
|
|
361
|
-
arg = `${arg}`;
|
|
362
|
-
|
|
363
|
-
// Algorithm below is based on https://qntm.org/cmd
|
|
364
|
-
|
|
365
|
-
// Sequence of backslashes followed by a double quote:
|
|
366
|
-
// double up all the backslashes and escape the double quote
|
|
367
|
-
arg = arg.replace(/(\\*)"/g, '$1$1\\"');
|
|
368
|
-
|
|
369
|
-
// Sequence of backslashes followed by the end of the string
|
|
370
|
-
// (which will become a double quote later):
|
|
371
|
-
// double up all the backslashes
|
|
372
|
-
arg = arg.replace(/(\\*)$/, '$1$1');
|
|
373
|
-
|
|
374
|
-
// All other backslashes occur literally
|
|
375
|
-
|
|
376
|
-
// Quote the whole thing:
|
|
377
|
-
arg = `"${arg}"`;
|
|
378
|
-
|
|
379
|
-
// Escape meta chars
|
|
380
|
-
arg = arg.replace(metaCharsRegExp, '^$1');
|
|
381
|
-
|
|
382
|
-
// Double escape meta chars if necessary
|
|
383
|
-
if (doubleEscapeMetaChars) {
|
|
384
|
-
arg = arg.replace(metaCharsRegExp, '^$1');
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
return arg;
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
_escape.command = escapeCommand;
|
|
391
|
-
_escape.argument = escapeArgument;
|
|
392
|
-
|
|
393
|
-
var shebangRegex$1 = /^#!(.*)/;
|
|
394
|
-
|
|
395
|
-
const shebangRegex = shebangRegex$1;
|
|
396
|
-
|
|
397
|
-
var shebangCommand$1 = (string = '') => {
|
|
398
|
-
const match = string.match(shebangRegex);
|
|
399
|
-
|
|
400
|
-
if (!match) {
|
|
401
|
-
return null;
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
const [path, argument] = match[0].replace(/#! ?/, '').split(' ');
|
|
405
|
-
const binary = path.split('/').pop();
|
|
406
|
-
|
|
407
|
-
if (binary === 'env') {
|
|
408
|
-
return argument;
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
return argument ? `${binary} ${argument}` : binary;
|
|
412
|
-
};
|
|
413
|
-
|
|
414
|
-
const fs = fs$3;
|
|
415
|
-
const shebangCommand = shebangCommand$1;
|
|
416
|
-
|
|
417
|
-
function readShebang$1(command) {
|
|
418
|
-
// Read the first 150 bytes from the file
|
|
419
|
-
const size = 150;
|
|
420
|
-
const buffer = Buffer.alloc(size);
|
|
421
|
-
|
|
422
|
-
let fd;
|
|
423
|
-
|
|
424
|
-
try {
|
|
425
|
-
fd = fs.openSync(command, 'r');
|
|
426
|
-
fs.readSync(fd, buffer, 0, size, 0);
|
|
427
|
-
fs.closeSync(fd);
|
|
428
|
-
} catch (e) { /* Empty */ }
|
|
429
|
-
|
|
430
|
-
// Attempt to extract shebang (null is returned if not a shebang)
|
|
431
|
-
return shebangCommand(buffer.toString());
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
var readShebang_1 = readShebang$1;
|
|
435
|
-
|
|
436
|
-
const path = path$3;
|
|
437
|
-
const resolveCommand = resolveCommand_1;
|
|
438
|
-
const escape = _escape;
|
|
439
|
-
const readShebang = readShebang_1;
|
|
440
|
-
|
|
441
|
-
const isWin$1 = process.platform === 'win32';
|
|
442
|
-
const isExecutableRegExp = /\.(?:com|exe)$/i;
|
|
443
|
-
const isCmdShimRegExp = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
|
|
444
|
-
|
|
445
|
-
function detectShebang(parsed) {
|
|
446
|
-
parsed.file = resolveCommand(parsed);
|
|
447
|
-
|
|
448
|
-
const shebang = parsed.file && readShebang(parsed.file);
|
|
449
|
-
|
|
450
|
-
if (shebang) {
|
|
451
|
-
parsed.args.unshift(parsed.file);
|
|
452
|
-
parsed.command = shebang;
|
|
453
|
-
|
|
454
|
-
return resolveCommand(parsed);
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
return parsed.file;
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
function parseNonShell(parsed) {
|
|
461
|
-
if (!isWin$1) {
|
|
462
|
-
return parsed;
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
// Detect & add support for shebangs
|
|
466
|
-
const commandFile = detectShebang(parsed);
|
|
467
|
-
|
|
468
|
-
// We don't need a shell if the command filename is an executable
|
|
469
|
-
const needsShell = !isExecutableRegExp.test(commandFile);
|
|
470
|
-
|
|
471
|
-
// If a shell is required, use cmd.exe and take care of escaping everything correctly
|
|
472
|
-
// Note that `forceShell` is an hidden option used only in tests
|
|
473
|
-
if (parsed.options.forceShell || needsShell) {
|
|
474
|
-
// Need to double escape meta chars if the command is a cmd-shim located in `node_modules/.bin/`
|
|
475
|
-
// The cmd-shim simply calls execute the package bin file with NodeJS, proxying any argument
|
|
476
|
-
// Because the escape of metachars with ^ gets interpreted when the cmd.exe is first called,
|
|
477
|
-
// we need to double escape them
|
|
478
|
-
const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
|
|
479
|
-
|
|
480
|
-
// Normalize posix paths into OS compatible paths (e.g.: foo/bar -> foo\bar)
|
|
481
|
-
// This is necessary otherwise it will always fail with ENOENT in those cases
|
|
482
|
-
parsed.command = path.normalize(parsed.command);
|
|
483
|
-
|
|
484
|
-
// Escape command & arguments
|
|
485
|
-
parsed.command = escape.command(parsed.command);
|
|
486
|
-
parsed.args = parsed.args.map((arg) => escape.argument(arg, needsDoubleEscapeMetaChars));
|
|
487
|
-
|
|
488
|
-
const shellCommand = [parsed.command].concat(parsed.args).join(' ');
|
|
489
|
-
|
|
490
|
-
parsed.args = ['/d', '/s', '/c', `"${shellCommand}"`];
|
|
491
|
-
parsed.command = process.env.comspec || 'cmd.exe';
|
|
492
|
-
parsed.options.windowsVerbatimArguments = true; // Tell node's spawn that the arguments are already escaped
|
|
493
|
-
}
|
|
494
|
-
|
|
495
|
-
return parsed;
|
|
496
|
-
}
|
|
497
|
-
|
|
498
|
-
function parse$1(command, args, options) {
|
|
499
|
-
// Normalize arguments, similar to nodejs
|
|
500
|
-
if (args && !Array.isArray(args)) {
|
|
501
|
-
options = args;
|
|
502
|
-
args = null;
|
|
503
|
-
}
|
|
504
|
-
|
|
505
|
-
args = args ? args.slice(0) : []; // Clone array to avoid changing the original
|
|
506
|
-
options = Object.assign({}, options); // Clone object to avoid changing the original
|
|
507
|
-
|
|
508
|
-
// Build our parsed object
|
|
509
|
-
const parsed = {
|
|
510
|
-
command,
|
|
511
|
-
args,
|
|
512
|
-
options,
|
|
513
|
-
file: undefined,
|
|
514
|
-
original: {
|
|
515
|
-
command,
|
|
516
|
-
args,
|
|
517
|
-
},
|
|
518
|
-
};
|
|
519
|
-
|
|
520
|
-
// Delegate further parsing to shell or non-shell
|
|
521
|
-
return options.shell ? parsed : parseNonShell(parsed);
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
var parse_1 = parse$1;
|
|
525
|
-
|
|
526
|
-
const isWin = process.platform === 'win32';
|
|
527
|
-
|
|
528
|
-
function notFoundError(original, syscall) {
|
|
529
|
-
return Object.assign(new Error(`${syscall} ${original.command} ENOENT`), {
|
|
530
|
-
code: 'ENOENT',
|
|
531
|
-
errno: 'ENOENT',
|
|
532
|
-
syscall: `${syscall} ${original.command}`,
|
|
533
|
-
path: original.command,
|
|
534
|
-
spawnargs: original.args,
|
|
535
|
-
});
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
function hookChildProcess(cp, parsed) {
|
|
539
|
-
if (!isWin) {
|
|
540
|
-
return;
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
const originalEmit = cp.emit;
|
|
544
|
-
|
|
545
|
-
cp.emit = function (name, arg1) {
|
|
546
|
-
// If emitting "exit" event and exit code is 1, we need to check if
|
|
547
|
-
// the command exists and emit an "error" instead
|
|
548
|
-
// See https://github.com/IndigoUnited/node-cross-spawn/issues/16
|
|
549
|
-
if (name === 'exit') {
|
|
550
|
-
const err = verifyENOENT(arg1, parsed);
|
|
551
|
-
|
|
552
|
-
if (err) {
|
|
553
|
-
return originalEmit.call(cp, 'error', err);
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
|
-
|
|
557
|
-
return originalEmit.apply(cp, arguments); // eslint-disable-line prefer-rest-params
|
|
558
|
-
};
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
function verifyENOENT(status, parsed) {
|
|
562
|
-
if (isWin && status === 1 && !parsed.file) {
|
|
563
|
-
return notFoundError(parsed.original, 'spawn');
|
|
564
|
-
}
|
|
565
|
-
|
|
566
|
-
return null;
|
|
567
|
-
}
|
|
568
|
-
|
|
569
|
-
function verifyENOENTSync(status, parsed) {
|
|
570
|
-
if (isWin && status === 1 && !parsed.file) {
|
|
571
|
-
return notFoundError(parsed.original, 'spawnSync');
|
|
572
|
-
}
|
|
573
|
-
|
|
574
|
-
return null;
|
|
575
|
-
}
|
|
576
|
-
|
|
577
|
-
var enoent$1 = {
|
|
578
|
-
hookChildProcess,
|
|
579
|
-
verifyENOENT,
|
|
580
|
-
verifyENOENTSync,
|
|
581
|
-
notFoundError,
|
|
582
|
-
};
|
|
583
|
-
|
|
584
|
-
const cp = childProcess;
|
|
585
|
-
const parse = parse_1;
|
|
586
|
-
const enoent = enoent$1;
|
|
587
|
-
|
|
588
|
-
function spawn(command, args, options) {
|
|
589
|
-
// Parse the arguments
|
|
590
|
-
const parsed = parse(command, args, options);
|
|
591
|
-
|
|
592
|
-
// Spawn the child process
|
|
593
|
-
const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);
|
|
594
|
-
|
|
595
|
-
// Hook into child process "exit" event to emit an error if the command
|
|
596
|
-
// does not exists, see: https://github.com/IndigoUnited/node-cross-spawn/issues/16
|
|
597
|
-
enoent.hookChildProcess(spawned, parsed);
|
|
598
|
-
|
|
599
|
-
return spawned;
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
function spawnSync(command, args, options) {
|
|
603
|
-
// Parse the arguments
|
|
604
|
-
const parsed = parse(command, args, options);
|
|
605
|
-
|
|
606
|
-
// Spawn the child process
|
|
607
|
-
const result = cp.spawnSync(parsed.command, parsed.args, parsed.options);
|
|
608
|
-
|
|
609
|
-
// Analyze if the command does not exist, see: https://github.com/IndigoUnited/node-cross-spawn/issues/16
|
|
610
|
-
result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
|
|
611
|
-
|
|
612
|
-
return result;
|
|
613
|
-
}
|
|
614
|
-
|
|
615
|
-
crossSpawn$1.exports = spawn;
|
|
616
|
-
crossSpawn$1.exports.spawn = spawn;
|
|
617
|
-
crossSpawn$1.exports.sync = spawnSync;
|
|
618
|
-
|
|
619
|
-
crossSpawn$1.exports._parse = parse;
|
|
620
|
-
crossSpawn$1.exports._enoent = enoent;
|
|
621
|
-
|
|
622
|
-
var crossSpawn = crossSpawn$1.exports;
|
|
623
|
-
|
|
624
|
-
var getStream$2 = {exports: {}};
|
|
625
|
-
|
|
626
|
-
const {PassThrough: PassThroughStream} = require$$0;
|
|
627
|
-
|
|
628
|
-
var bufferStream$1 = options => {
|
|
629
|
-
options = {...options};
|
|
630
|
-
|
|
631
|
-
const {array} = options;
|
|
632
|
-
let {encoding} = options;
|
|
633
|
-
const isBuffer = encoding === 'buffer';
|
|
634
|
-
let objectMode = false;
|
|
635
|
-
|
|
636
|
-
if (array) {
|
|
637
|
-
objectMode = !(encoding || isBuffer);
|
|
638
|
-
} else {
|
|
639
|
-
encoding = encoding || 'utf8';
|
|
640
|
-
}
|
|
641
|
-
|
|
642
|
-
if (isBuffer) {
|
|
643
|
-
encoding = null;
|
|
644
|
-
}
|
|
645
|
-
|
|
646
|
-
const stream = new PassThroughStream({objectMode});
|
|
647
|
-
|
|
648
|
-
if (encoding) {
|
|
649
|
-
stream.setEncoding(encoding);
|
|
650
|
-
}
|
|
651
|
-
|
|
652
|
-
let length = 0;
|
|
653
|
-
const chunks = [];
|
|
654
|
-
|
|
655
|
-
stream.on('data', chunk => {
|
|
656
|
-
chunks.push(chunk);
|
|
657
|
-
|
|
658
|
-
if (objectMode) {
|
|
659
|
-
length = chunks.length;
|
|
660
|
-
} else {
|
|
661
|
-
length += chunk.length;
|
|
662
|
-
}
|
|
663
|
-
});
|
|
664
|
-
|
|
665
|
-
stream.getBufferedValue = () => {
|
|
666
|
-
if (array) {
|
|
667
|
-
return chunks;
|
|
668
|
-
}
|
|
669
|
-
|
|
670
|
-
return isBuffer ? Buffer.concat(chunks, length) : chunks.join('');
|
|
671
|
-
};
|
|
672
|
-
|
|
673
|
-
stream.getBufferedLength = () => length;
|
|
674
|
-
|
|
675
|
-
return stream;
|
|
676
|
-
};
|
|
677
|
-
|
|
678
|
-
const {constants: BufferConstants} = require$$0$2;
|
|
679
|
-
const stream = require$$0;
|
|
680
|
-
const {promisify} = require$$0$1;
|
|
681
|
-
const bufferStream = bufferStream$1;
|
|
682
|
-
|
|
683
|
-
const streamPipelinePromisified = promisify(stream.pipeline);
|
|
684
|
-
|
|
685
|
-
class MaxBufferError extends Error {
|
|
686
|
-
constructor() {
|
|
687
|
-
super('maxBuffer exceeded');
|
|
688
|
-
this.name = 'MaxBufferError';
|
|
689
|
-
}
|
|
690
|
-
}
|
|
691
|
-
|
|
692
|
-
async function getStream(inputStream, options) {
|
|
693
|
-
if (!inputStream) {
|
|
694
|
-
throw new Error('Expected a stream');
|
|
695
|
-
}
|
|
696
|
-
|
|
697
|
-
options = {
|
|
698
|
-
maxBuffer: Infinity,
|
|
699
|
-
...options
|
|
700
|
-
};
|
|
701
|
-
|
|
702
|
-
const {maxBuffer} = options;
|
|
703
|
-
const stream = bufferStream(options);
|
|
704
|
-
|
|
705
|
-
await new Promise((resolve, reject) => {
|
|
706
|
-
const rejectPromise = error => {
|
|
707
|
-
// Don't retrieve an oversized buffer.
|
|
708
|
-
if (error && stream.getBufferedLength() <= BufferConstants.MAX_LENGTH) {
|
|
709
|
-
error.bufferedData = stream.getBufferedValue();
|
|
710
|
-
}
|
|
711
|
-
|
|
712
|
-
reject(error);
|
|
713
|
-
};
|
|
714
|
-
|
|
715
|
-
(async () => {
|
|
716
|
-
try {
|
|
717
|
-
await streamPipelinePromisified(inputStream, stream);
|
|
718
|
-
resolve();
|
|
719
|
-
} catch (error) {
|
|
720
|
-
rejectPromise(error);
|
|
721
|
-
}
|
|
722
|
-
})();
|
|
723
|
-
|
|
724
|
-
stream.on('data', () => {
|
|
725
|
-
if (stream.getBufferedLength() > maxBuffer) {
|
|
726
|
-
rejectPromise(new MaxBufferError());
|
|
727
|
-
}
|
|
728
|
-
});
|
|
729
|
-
});
|
|
730
|
-
|
|
731
|
-
return stream.getBufferedValue();
|
|
732
|
-
}
|
|
733
|
-
|
|
734
|
-
getStream$2.exports = getStream;
|
|
735
|
-
getStream$2.exports.buffer = (stream, options) => getStream(stream, {...options, encoding: 'buffer'});
|
|
736
|
-
getStream$2.exports.array = (stream, options) => getStream(stream, {...options, array: true});
|
|
737
|
-
getStream$2.exports.MaxBufferError = MaxBufferError;
|
|
738
|
-
|
|
739
|
-
var getStream$1 = getStream$2.exports;
|
|
740
|
-
|
|
741
|
-
const { PassThrough } = require$$0;
|
|
742
|
-
|
|
743
|
-
var mergeStream = function (/*streams...*/) {
|
|
744
|
-
var sources = [];
|
|
745
|
-
var output = new PassThrough({objectMode: true});
|
|
746
|
-
|
|
747
|
-
output.setMaxListeners(0);
|
|
748
|
-
|
|
749
|
-
output.add = add;
|
|
750
|
-
output.isEmpty = isEmpty;
|
|
751
|
-
|
|
752
|
-
output.on('unpipe', remove);
|
|
753
|
-
|
|
754
|
-
Array.prototype.slice.call(arguments).forEach(add);
|
|
755
|
-
|
|
756
|
-
return output
|
|
757
|
-
|
|
758
|
-
function add (source) {
|
|
759
|
-
if (Array.isArray(source)) {
|
|
760
|
-
source.forEach(add);
|
|
761
|
-
return this
|
|
762
|
-
}
|
|
763
|
-
|
|
764
|
-
sources.push(source);
|
|
765
|
-
source.once('end', remove.bind(null, source));
|
|
766
|
-
source.once('error', output.emit.bind(output, 'error'));
|
|
767
|
-
source.pipe(output, {end: false});
|
|
768
|
-
return this
|
|
769
|
-
}
|
|
770
|
-
|
|
771
|
-
function isEmpty () {
|
|
772
|
-
return sources.length == 0;
|
|
773
|
-
}
|
|
774
|
-
|
|
775
|
-
function remove (source) {
|
|
776
|
-
sources = sources.filter(function (it) { return it !== source });
|
|
777
|
-
if (!sources.length && output.readable) { output.end(); }
|
|
778
|
-
}
|
|
779
|
-
};
|
|
780
|
-
|
|
781
|
-
export { getStream$2 as a, crossSpawn$1 as b, crossSpawn as c, getStream$1 as g, mergeStream as m, pathKey$1 as p };
|