vitest 1.0.0-beta.4 → 1.0.0-beta.5
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/LICENSE.md +1 -513
- package/dist/browser.d.ts +1 -1
- package/dist/browser.js +4 -4
- package/dist/child.js +13 -17
- package/dist/{chunk-api-setup.6d19ab38.js → chunks/api-setup.jHV5vgr2.js} +97 -39
- package/dist/chunks/install-pkg.ORGzQeqb.js +457 -0
- package/dist/chunks/integrations-globals.-pds_Gug.js +29 -0
- package/dist/{chunk-node-git.6c12e560.js → chunks/node-git.Hw101KjS.js} +1 -18
- package/dist/{chunk-runtime-console.f3263f87.js → chunks/runtime-console.iCAG0Yz3.js} +1 -1
- package/dist/cli-wrapper.js +2 -18
- package/dist/cli.js +18 -23
- package/dist/config.cjs +1 -1
- package/dist/config.d.ts +4 -6
- package/dist/config.js +1 -1
- package/dist/coverage.d.ts +25 -15
- package/dist/coverage.js +118 -49
- package/dist/entry-vm.js +13 -13
- package/dist/entry.js +14 -14
- package/dist/environments.d.ts +1 -1
- package/dist/environments.js +1 -1
- package/dist/execute.d.ts +1 -1
- package/dist/execute.js +3 -3
- package/dist/index.d.ts +166 -38
- package/dist/index.js +10 -10
- package/dist/node.d.ts +5 -5
- package/dist/node.js +17 -22
- package/dist/{vendor-paths.84fc7a99.js → paths.js} +1 -1
- package/dist/{reporters-50c2bd49.d.ts → reporters-ANEBTnOh.d.ts} +324 -361
- package/dist/reporters.d.ts +1 -1
- package/dist/reporters.js +7 -8
- package/dist/runners.d.ts +1 -1
- package/dist/runners.js +8 -8
- package/dist/{suite-ad69b7cd.d.ts → suite-C1OmA61l.d.ts} +1 -1
- package/dist/suite.d.ts +2 -2
- package/dist/suite.js +3 -3
- package/dist/{vendor-benchmark.b6befc50.js → vendor/benchmark.WVm6DARl.js} +1 -1
- package/dist/{vendor-execute.157302d6.js → vendor/execute.aMjV5C9u.js} +2 -4
- package/dist/{vendor-index.72df742e.js → vendor/index.Npc-eff0.js} +4 -4
- package/dist/{vendor-index.2b92937b.js → vendor/index.XU72Rmy8.js} +1 -1
- package/dist/{vendor-index.57925a34.js → vendor/index.h0j9y5vy.js} +5 -5
- package/dist/vendor/index.xL8XjTLv.js +3962 -0
- package/dist/vendor/loader.CU0NY2Is.js +39 -0
- package/dist/{vendor-node.65461b16.js → vendor/node.c-kzGvOB.js} +1874 -5960
- package/dist/{vendor-reporters.d24d80a4.js → vendor/reporters.1xKxm8im.js} +424 -374
- package/dist/{vendor-rpc.171f65fb.js → vendor/rpc.Bl-ysZIr.js} +1 -1
- package/dist/{vendor-run-once.fb836747.js → vendor/run-once.X3E7xx3F.js} +1 -1
- package/dist/{vendor-vi.3baa7c4a.js → vendor/vi.voNYQWB_.js} +4 -4
- package/dist/vm.js +13 -18
- package/dist/worker.js +13 -18
- package/index.cjs +5 -0
- package/package.json +49 -53
- package/dist/chunk-install-pkg.e1d6323e.js +0 -1740
- package/dist/chunk-integrations-globals.2b099e04.js +0 -29
- package/dist/vendor-index.8efe7746.js +0 -2236
- package/dist/vendor-loader.9c966f23.js +0 -2089
- /package/dist/{vendor-_commonjsHelpers.7d1333e8.js → vendor/_commonjsHelpers.jjO7Zipk.js} +0 -0
- /package/dist/{vendor-base.9c08bbd0.js → vendor/base._79unx2z.js} +0 -0
- /package/dist/{vendor-constants.538d9b49.js → vendor/constants.WSvnD_fn.js} +0 -0
- /package/dist/{vendor-coverage.78040316.js → vendor/coverage.v6aD8iAh.js} +0 -0
- /package/dist/{vendor-date.6e993429.js → vendor/date.W90-E5kF.js} +0 -0
- /package/dist/{vendor-environments.dcc4a34e.js → vendor/environments.hpEVJZPC.js} +0 -0
- /package/dist/{vendor-global.c3664e75.js → vendor/global.L7JRz1qU.js} +0 -0
- /package/dist/{vendor-index.1ca68bd5.js → vendor/index.cAUulNDf.js} +0 -0
- /package/dist/{vendor-inspector.209edf5a.js → vendor/inspector.lFAeuaAt.js} +0 -0
- /package/dist/{vendor-tasks.f9d75aed.js → vendor/tasks.IknbGB2n.js} +0 -0
|
@@ -1,2236 +0,0 @@
|
|
|
1
|
-
import { Buffer as Buffer$1 } from 'node:buffer';
|
|
2
|
-
import path$3 from 'node:path';
|
|
3
|
-
import childProcess, { ChildProcess } from 'node:child_process';
|
|
4
|
-
import process$2 from 'node:process';
|
|
5
|
-
import { c as commonjsGlobal, g as getDefaultExportFromCjs } from './vendor-_commonjsHelpers.7d1333e8.js';
|
|
6
|
-
import require$$0 from 'child_process';
|
|
7
|
-
import f from 'path';
|
|
8
|
-
import $ from 'fs';
|
|
9
|
-
import url from 'node:url';
|
|
10
|
-
import nodeos__default, { constants } from 'node:os';
|
|
11
|
-
import require$$0$1 from 'assert';
|
|
12
|
-
import require$$2 from 'events';
|
|
13
|
-
import { createWriteStream, createReadStream } from 'node:fs';
|
|
14
|
-
import require$$0$4 from 'buffer';
|
|
15
|
-
import require$$0$2 from 'stream';
|
|
16
|
-
import require$$0$3 from 'util';
|
|
17
|
-
import { debuglog } from 'node:util';
|
|
18
|
-
|
|
19
|
-
var crossSpawn$1 = {exports: {}};
|
|
20
|
-
|
|
21
|
-
var windows;
|
|
22
|
-
var hasRequiredWindows;
|
|
23
|
-
|
|
24
|
-
function requireWindows () {
|
|
25
|
-
if (hasRequiredWindows) return windows;
|
|
26
|
-
hasRequiredWindows = 1;
|
|
27
|
-
windows = isexe;
|
|
28
|
-
isexe.sync = sync;
|
|
29
|
-
|
|
30
|
-
var fs = $;
|
|
31
|
-
|
|
32
|
-
function checkPathExt (path, options) {
|
|
33
|
-
var pathext = options.pathExt !== undefined ?
|
|
34
|
-
options.pathExt : process.env.PATHEXT;
|
|
35
|
-
|
|
36
|
-
if (!pathext) {
|
|
37
|
-
return true
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
pathext = pathext.split(';');
|
|
41
|
-
if (pathext.indexOf('') !== -1) {
|
|
42
|
-
return true
|
|
43
|
-
}
|
|
44
|
-
for (var i = 0; i < pathext.length; i++) {
|
|
45
|
-
var p = pathext[i].toLowerCase();
|
|
46
|
-
if (p && path.substr(-p.length).toLowerCase() === p) {
|
|
47
|
-
return true
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
return false
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function checkStat (stat, path, options) {
|
|
54
|
-
if (!stat.isSymbolicLink() && !stat.isFile()) {
|
|
55
|
-
return false
|
|
56
|
-
}
|
|
57
|
-
return checkPathExt(path, options)
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function isexe (path, options, cb) {
|
|
61
|
-
fs.stat(path, function (er, stat) {
|
|
62
|
-
cb(er, er ? false : checkStat(stat, path, options));
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
function sync (path, options) {
|
|
67
|
-
return checkStat(fs.statSync(path), path, options)
|
|
68
|
-
}
|
|
69
|
-
return windows;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
var mode;
|
|
73
|
-
var hasRequiredMode;
|
|
74
|
-
|
|
75
|
-
function requireMode () {
|
|
76
|
-
if (hasRequiredMode) return mode;
|
|
77
|
-
hasRequiredMode = 1;
|
|
78
|
-
mode = isexe;
|
|
79
|
-
isexe.sync = sync;
|
|
80
|
-
|
|
81
|
-
var fs = $;
|
|
82
|
-
|
|
83
|
-
function isexe (path, options, cb) {
|
|
84
|
-
fs.stat(path, function (er, stat) {
|
|
85
|
-
cb(er, er ? false : checkStat(stat, options));
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
function sync (path, options) {
|
|
90
|
-
return checkStat(fs.statSync(path), options)
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
function checkStat (stat, options) {
|
|
94
|
-
return stat.isFile() && checkMode(stat, options)
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
function checkMode (stat, options) {
|
|
98
|
-
var mod = stat.mode;
|
|
99
|
-
var uid = stat.uid;
|
|
100
|
-
var gid = stat.gid;
|
|
101
|
-
|
|
102
|
-
var myUid = options.uid !== undefined ?
|
|
103
|
-
options.uid : process.getuid && process.getuid();
|
|
104
|
-
var myGid = options.gid !== undefined ?
|
|
105
|
-
options.gid : process.getgid && process.getgid();
|
|
106
|
-
|
|
107
|
-
var u = parseInt('100', 8);
|
|
108
|
-
var g = parseInt('010', 8);
|
|
109
|
-
var o = parseInt('001', 8);
|
|
110
|
-
var ug = u | g;
|
|
111
|
-
|
|
112
|
-
var ret = (mod & o) ||
|
|
113
|
-
(mod & g) && gid === myGid ||
|
|
114
|
-
(mod & u) && uid === myUid ||
|
|
115
|
-
(mod & ug) && myUid === 0;
|
|
116
|
-
|
|
117
|
-
return ret
|
|
118
|
-
}
|
|
119
|
-
return mode;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
var core;
|
|
123
|
-
if (process.platform === 'win32' || commonjsGlobal.TESTING_WINDOWS) {
|
|
124
|
-
core = requireWindows();
|
|
125
|
-
} else {
|
|
126
|
-
core = requireMode();
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
var isexe_1 = isexe$1;
|
|
130
|
-
isexe$1.sync = sync;
|
|
131
|
-
|
|
132
|
-
function isexe$1 (path, options, cb) {
|
|
133
|
-
if (typeof options === 'function') {
|
|
134
|
-
cb = options;
|
|
135
|
-
options = {};
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
if (!cb) {
|
|
139
|
-
if (typeof Promise !== 'function') {
|
|
140
|
-
throw new TypeError('callback not provided')
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
return new Promise(function (resolve, reject) {
|
|
144
|
-
isexe$1(path, options || {}, function (er, is) {
|
|
145
|
-
if (er) {
|
|
146
|
-
reject(er);
|
|
147
|
-
} else {
|
|
148
|
-
resolve(is);
|
|
149
|
-
}
|
|
150
|
-
});
|
|
151
|
-
})
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
core(path, options || {}, function (er, is) {
|
|
155
|
-
// ignore EACCES because that just means we aren't allowed to run it
|
|
156
|
-
if (er) {
|
|
157
|
-
if (er.code === 'EACCES' || options && options.ignoreErrors) {
|
|
158
|
-
er = null;
|
|
159
|
-
is = false;
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
cb(er, is);
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
function sync (path, options) {
|
|
167
|
-
// my kingdom for a filtered catch
|
|
168
|
-
try {
|
|
169
|
-
return core.sync(path, options || {})
|
|
170
|
-
} catch (er) {
|
|
171
|
-
if (options && options.ignoreErrors || er.code === 'EACCES') {
|
|
172
|
-
return false
|
|
173
|
-
} else {
|
|
174
|
-
throw er
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
const isWindows = process.platform === 'win32' ||
|
|
180
|
-
process.env.OSTYPE === 'cygwin' ||
|
|
181
|
-
process.env.OSTYPE === 'msys';
|
|
182
|
-
|
|
183
|
-
const path$2 = f;
|
|
184
|
-
const COLON = isWindows ? ';' : ':';
|
|
185
|
-
const isexe = isexe_1;
|
|
186
|
-
|
|
187
|
-
const getNotFoundError = (cmd) =>
|
|
188
|
-
Object.assign(new Error(`not found: ${cmd}`), { code: 'ENOENT' });
|
|
189
|
-
|
|
190
|
-
const getPathInfo = (cmd, opt) => {
|
|
191
|
-
const colon = opt.colon || COLON;
|
|
192
|
-
|
|
193
|
-
// If it has a slash, then we don't bother searching the pathenv.
|
|
194
|
-
// just check the file itself, and that's it.
|
|
195
|
-
const pathEnv = cmd.match(/\//) || isWindows && cmd.match(/\\/) ? ['']
|
|
196
|
-
: (
|
|
197
|
-
[
|
|
198
|
-
// windows always checks the cwd first
|
|
199
|
-
...(isWindows ? [process.cwd()] : []),
|
|
200
|
-
...(opt.path || process.env.PATH ||
|
|
201
|
-
/* istanbul ignore next: very unusual */ '').split(colon),
|
|
202
|
-
]
|
|
203
|
-
);
|
|
204
|
-
const pathExtExe = isWindows
|
|
205
|
-
? opt.pathExt || process.env.PATHEXT || '.EXE;.CMD;.BAT;.COM'
|
|
206
|
-
: '';
|
|
207
|
-
const pathExt = isWindows ? pathExtExe.split(colon) : [''];
|
|
208
|
-
|
|
209
|
-
if (isWindows) {
|
|
210
|
-
if (cmd.indexOf('.') !== -1 && pathExt[0] !== '')
|
|
211
|
-
pathExt.unshift('');
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
return {
|
|
215
|
-
pathEnv,
|
|
216
|
-
pathExt,
|
|
217
|
-
pathExtExe,
|
|
218
|
-
}
|
|
219
|
-
};
|
|
220
|
-
|
|
221
|
-
const which$1 = (cmd, opt, cb) => {
|
|
222
|
-
if (typeof opt === 'function') {
|
|
223
|
-
cb = opt;
|
|
224
|
-
opt = {};
|
|
225
|
-
}
|
|
226
|
-
if (!opt)
|
|
227
|
-
opt = {};
|
|
228
|
-
|
|
229
|
-
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
|
|
230
|
-
const found = [];
|
|
231
|
-
|
|
232
|
-
const step = i => new Promise((resolve, reject) => {
|
|
233
|
-
if (i === pathEnv.length)
|
|
234
|
-
return opt.all && found.length ? resolve(found)
|
|
235
|
-
: reject(getNotFoundError(cmd))
|
|
236
|
-
|
|
237
|
-
const ppRaw = pathEnv[i];
|
|
238
|
-
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
239
|
-
|
|
240
|
-
const pCmd = path$2.join(pathPart, cmd);
|
|
241
|
-
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd
|
|
242
|
-
: pCmd;
|
|
243
|
-
|
|
244
|
-
resolve(subStep(p, i, 0));
|
|
245
|
-
});
|
|
246
|
-
|
|
247
|
-
const subStep = (p, i, ii) => new Promise((resolve, reject) => {
|
|
248
|
-
if (ii === pathExt.length)
|
|
249
|
-
return resolve(step(i + 1))
|
|
250
|
-
const ext = pathExt[ii];
|
|
251
|
-
isexe(p + ext, { pathExt: pathExtExe }, (er, is) => {
|
|
252
|
-
if (!er && is) {
|
|
253
|
-
if (opt.all)
|
|
254
|
-
found.push(p + ext);
|
|
255
|
-
else
|
|
256
|
-
return resolve(p + ext)
|
|
257
|
-
}
|
|
258
|
-
return resolve(subStep(p, i, ii + 1))
|
|
259
|
-
});
|
|
260
|
-
});
|
|
261
|
-
|
|
262
|
-
return cb ? step(0).then(res => cb(null, res), cb) : step(0)
|
|
263
|
-
};
|
|
264
|
-
|
|
265
|
-
const whichSync = (cmd, opt) => {
|
|
266
|
-
opt = opt || {};
|
|
267
|
-
|
|
268
|
-
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
|
|
269
|
-
const found = [];
|
|
270
|
-
|
|
271
|
-
for (let i = 0; i < pathEnv.length; i ++) {
|
|
272
|
-
const ppRaw = pathEnv[i];
|
|
273
|
-
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
274
|
-
|
|
275
|
-
const pCmd = path$2.join(pathPart, cmd);
|
|
276
|
-
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd
|
|
277
|
-
: pCmd;
|
|
278
|
-
|
|
279
|
-
for (let j = 0; j < pathExt.length; j ++) {
|
|
280
|
-
const cur = p + pathExt[j];
|
|
281
|
-
try {
|
|
282
|
-
const is = isexe.sync(cur, { pathExt: pathExtExe });
|
|
283
|
-
if (is) {
|
|
284
|
-
if (opt.all)
|
|
285
|
-
found.push(cur);
|
|
286
|
-
else
|
|
287
|
-
return cur
|
|
288
|
-
}
|
|
289
|
-
} catch (ex) {}
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
if (opt.all && found.length)
|
|
294
|
-
return found
|
|
295
|
-
|
|
296
|
-
if (opt.nothrow)
|
|
297
|
-
return null
|
|
298
|
-
|
|
299
|
-
throw getNotFoundError(cmd)
|
|
300
|
-
};
|
|
301
|
-
|
|
302
|
-
var which_1 = which$1;
|
|
303
|
-
which$1.sync = whichSync;
|
|
304
|
-
|
|
305
|
-
var pathKey$2 = {exports: {}};
|
|
306
|
-
|
|
307
|
-
const pathKey$1 = (options = {}) => {
|
|
308
|
-
const environment = options.env || process.env;
|
|
309
|
-
const platform = options.platform || process.platform;
|
|
310
|
-
|
|
311
|
-
if (platform !== 'win32') {
|
|
312
|
-
return 'PATH';
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
return Object.keys(environment).reverse().find(key => key.toUpperCase() === 'PATH') || 'Path';
|
|
316
|
-
};
|
|
317
|
-
|
|
318
|
-
pathKey$2.exports = pathKey$1;
|
|
319
|
-
// TODO: Remove this for the next major release
|
|
320
|
-
pathKey$2.exports.default = pathKey$1;
|
|
321
|
-
|
|
322
|
-
var pathKeyExports = pathKey$2.exports;
|
|
323
|
-
|
|
324
|
-
const path$1 = f;
|
|
325
|
-
const which = which_1;
|
|
326
|
-
const getPathKey = pathKeyExports;
|
|
327
|
-
|
|
328
|
-
function resolveCommandAttempt(parsed, withoutPathExt) {
|
|
329
|
-
const env = parsed.options.env || process.env;
|
|
330
|
-
const cwd = process.cwd();
|
|
331
|
-
const hasCustomCwd = parsed.options.cwd != null;
|
|
332
|
-
// Worker threads do not have process.chdir()
|
|
333
|
-
const shouldSwitchCwd = hasCustomCwd && process.chdir !== undefined && !process.chdir.disabled;
|
|
334
|
-
|
|
335
|
-
// If a custom `cwd` was specified, we need to change the process cwd
|
|
336
|
-
// because `which` will do stat calls but does not support a custom cwd
|
|
337
|
-
if (shouldSwitchCwd) {
|
|
338
|
-
try {
|
|
339
|
-
process.chdir(parsed.options.cwd);
|
|
340
|
-
} catch (err) {
|
|
341
|
-
/* Empty */
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
let resolved;
|
|
346
|
-
|
|
347
|
-
try {
|
|
348
|
-
resolved = which.sync(parsed.command, {
|
|
349
|
-
path: env[getPathKey({ env })],
|
|
350
|
-
pathExt: withoutPathExt ? path$1.delimiter : undefined,
|
|
351
|
-
});
|
|
352
|
-
} catch (e) {
|
|
353
|
-
/* Empty */
|
|
354
|
-
} finally {
|
|
355
|
-
if (shouldSwitchCwd) {
|
|
356
|
-
process.chdir(cwd);
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
// If we successfully resolved, ensure that an absolute path is returned
|
|
361
|
-
// Note that when a custom `cwd` was used, we need to resolve to an absolute path based on it
|
|
362
|
-
if (resolved) {
|
|
363
|
-
resolved = path$1.resolve(hasCustomCwd ? parsed.options.cwd : '', resolved);
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
return resolved;
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
function resolveCommand$1(parsed) {
|
|
370
|
-
return resolveCommandAttempt(parsed) || resolveCommandAttempt(parsed, true);
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
var resolveCommand_1 = resolveCommand$1;
|
|
374
|
-
|
|
375
|
-
var _escape = {};
|
|
376
|
-
|
|
377
|
-
// See http://www.robvanderwoude.com/escapechars.php
|
|
378
|
-
const metaCharsRegExp = /([()\][%!^"`<>&|;, *?])/g;
|
|
379
|
-
|
|
380
|
-
function escapeCommand(arg) {
|
|
381
|
-
// Escape meta chars
|
|
382
|
-
arg = arg.replace(metaCharsRegExp, '^$1');
|
|
383
|
-
|
|
384
|
-
return arg;
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
function escapeArgument(arg, doubleEscapeMetaChars) {
|
|
388
|
-
// Convert to string
|
|
389
|
-
arg = `${arg}`;
|
|
390
|
-
|
|
391
|
-
// Algorithm below is based on https://qntm.org/cmd
|
|
392
|
-
|
|
393
|
-
// Sequence of backslashes followed by a double quote:
|
|
394
|
-
// double up all the backslashes and escape the double quote
|
|
395
|
-
arg = arg.replace(/(\\*)"/g, '$1$1\\"');
|
|
396
|
-
|
|
397
|
-
// Sequence of backslashes followed by the end of the string
|
|
398
|
-
// (which will become a double quote later):
|
|
399
|
-
// double up all the backslashes
|
|
400
|
-
arg = arg.replace(/(\\*)$/, '$1$1');
|
|
401
|
-
|
|
402
|
-
// All other backslashes occur literally
|
|
403
|
-
|
|
404
|
-
// Quote the whole thing:
|
|
405
|
-
arg = `"${arg}"`;
|
|
406
|
-
|
|
407
|
-
// Escape meta chars
|
|
408
|
-
arg = arg.replace(metaCharsRegExp, '^$1');
|
|
409
|
-
|
|
410
|
-
// Double escape meta chars if necessary
|
|
411
|
-
if (doubleEscapeMetaChars) {
|
|
412
|
-
arg = arg.replace(metaCharsRegExp, '^$1');
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
return arg;
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
_escape.command = escapeCommand;
|
|
419
|
-
_escape.argument = escapeArgument;
|
|
420
|
-
|
|
421
|
-
var shebangRegex$1 = /^#!(.*)/;
|
|
422
|
-
|
|
423
|
-
const shebangRegex = shebangRegex$1;
|
|
424
|
-
|
|
425
|
-
var shebangCommand$1 = (string = '') => {
|
|
426
|
-
const match = string.match(shebangRegex);
|
|
427
|
-
|
|
428
|
-
if (!match) {
|
|
429
|
-
return null;
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
const [path, argument] = match[0].replace(/#! ?/, '').split(' ');
|
|
433
|
-
const binary = path.split('/').pop();
|
|
434
|
-
|
|
435
|
-
if (binary === 'env') {
|
|
436
|
-
return argument;
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
return argument ? `${binary} ${argument}` : binary;
|
|
440
|
-
};
|
|
441
|
-
|
|
442
|
-
const fs = $;
|
|
443
|
-
const shebangCommand = shebangCommand$1;
|
|
444
|
-
|
|
445
|
-
function readShebang$1(command) {
|
|
446
|
-
// Read the first 150 bytes from the file
|
|
447
|
-
const size = 150;
|
|
448
|
-
const buffer = Buffer.alloc(size);
|
|
449
|
-
|
|
450
|
-
let fd;
|
|
451
|
-
|
|
452
|
-
try {
|
|
453
|
-
fd = fs.openSync(command, 'r');
|
|
454
|
-
fs.readSync(fd, buffer, 0, size, 0);
|
|
455
|
-
fs.closeSync(fd);
|
|
456
|
-
} catch (e) { /* Empty */ }
|
|
457
|
-
|
|
458
|
-
// Attempt to extract shebang (null is returned if not a shebang)
|
|
459
|
-
return shebangCommand(buffer.toString());
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
var readShebang_1 = readShebang$1;
|
|
463
|
-
|
|
464
|
-
const path = f;
|
|
465
|
-
const resolveCommand = resolveCommand_1;
|
|
466
|
-
const escape = _escape;
|
|
467
|
-
const readShebang = readShebang_1;
|
|
468
|
-
|
|
469
|
-
const isWin$2 = process.platform === 'win32';
|
|
470
|
-
const isExecutableRegExp = /\.(?:com|exe)$/i;
|
|
471
|
-
const isCmdShimRegExp = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
|
|
472
|
-
|
|
473
|
-
function detectShebang(parsed) {
|
|
474
|
-
parsed.file = resolveCommand(parsed);
|
|
475
|
-
|
|
476
|
-
const shebang = parsed.file && readShebang(parsed.file);
|
|
477
|
-
|
|
478
|
-
if (shebang) {
|
|
479
|
-
parsed.args.unshift(parsed.file);
|
|
480
|
-
parsed.command = shebang;
|
|
481
|
-
|
|
482
|
-
return resolveCommand(parsed);
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
return parsed.file;
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
function parseNonShell(parsed) {
|
|
489
|
-
if (!isWin$2) {
|
|
490
|
-
return parsed;
|
|
491
|
-
}
|
|
492
|
-
|
|
493
|
-
// Detect & add support for shebangs
|
|
494
|
-
const commandFile = detectShebang(parsed);
|
|
495
|
-
|
|
496
|
-
// We don't need a shell if the command filename is an executable
|
|
497
|
-
const needsShell = !isExecutableRegExp.test(commandFile);
|
|
498
|
-
|
|
499
|
-
// If a shell is required, use cmd.exe and take care of escaping everything correctly
|
|
500
|
-
// Note that `forceShell` is an hidden option used only in tests
|
|
501
|
-
if (parsed.options.forceShell || needsShell) {
|
|
502
|
-
// Need to double escape meta chars if the command is a cmd-shim located in `node_modules/.bin/`
|
|
503
|
-
// The cmd-shim simply calls execute the package bin file with NodeJS, proxying any argument
|
|
504
|
-
// Because the escape of metachars with ^ gets interpreted when the cmd.exe is first called,
|
|
505
|
-
// we need to double escape them
|
|
506
|
-
const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
|
|
507
|
-
|
|
508
|
-
// Normalize posix paths into OS compatible paths (e.g.: foo/bar -> foo\bar)
|
|
509
|
-
// This is necessary otherwise it will always fail with ENOENT in those cases
|
|
510
|
-
parsed.command = path.normalize(parsed.command);
|
|
511
|
-
|
|
512
|
-
// Escape command & arguments
|
|
513
|
-
parsed.command = escape.command(parsed.command);
|
|
514
|
-
parsed.args = parsed.args.map((arg) => escape.argument(arg, needsDoubleEscapeMetaChars));
|
|
515
|
-
|
|
516
|
-
const shellCommand = [parsed.command].concat(parsed.args).join(' ');
|
|
517
|
-
|
|
518
|
-
parsed.args = ['/d', '/s', '/c', `"${shellCommand}"`];
|
|
519
|
-
parsed.command = process.env.comspec || 'cmd.exe';
|
|
520
|
-
parsed.options.windowsVerbatimArguments = true; // Tell node's spawn that the arguments are already escaped
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
return parsed;
|
|
524
|
-
}
|
|
525
|
-
|
|
526
|
-
function parse$1(command, args, options) {
|
|
527
|
-
// Normalize arguments, similar to nodejs
|
|
528
|
-
if (args && !Array.isArray(args)) {
|
|
529
|
-
options = args;
|
|
530
|
-
args = null;
|
|
531
|
-
}
|
|
532
|
-
|
|
533
|
-
args = args ? args.slice(0) : []; // Clone array to avoid changing the original
|
|
534
|
-
options = Object.assign({}, options); // Clone object to avoid changing the original
|
|
535
|
-
|
|
536
|
-
// Build our parsed object
|
|
537
|
-
const parsed = {
|
|
538
|
-
command,
|
|
539
|
-
args,
|
|
540
|
-
options,
|
|
541
|
-
file: undefined,
|
|
542
|
-
original: {
|
|
543
|
-
command,
|
|
544
|
-
args,
|
|
545
|
-
},
|
|
546
|
-
};
|
|
547
|
-
|
|
548
|
-
// Delegate further parsing to shell or non-shell
|
|
549
|
-
return options.shell ? parsed : parseNonShell(parsed);
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
var parse_1 = parse$1;
|
|
553
|
-
|
|
554
|
-
const isWin$1 = process.platform === 'win32';
|
|
555
|
-
|
|
556
|
-
function notFoundError(original, syscall) {
|
|
557
|
-
return Object.assign(new Error(`${syscall} ${original.command} ENOENT`), {
|
|
558
|
-
code: 'ENOENT',
|
|
559
|
-
errno: 'ENOENT',
|
|
560
|
-
syscall: `${syscall} ${original.command}`,
|
|
561
|
-
path: original.command,
|
|
562
|
-
spawnargs: original.args,
|
|
563
|
-
});
|
|
564
|
-
}
|
|
565
|
-
|
|
566
|
-
function hookChildProcess(cp, parsed) {
|
|
567
|
-
if (!isWin$1) {
|
|
568
|
-
return;
|
|
569
|
-
}
|
|
570
|
-
|
|
571
|
-
const originalEmit = cp.emit;
|
|
572
|
-
|
|
573
|
-
cp.emit = function (name, arg1) {
|
|
574
|
-
// If emitting "exit" event and exit code is 1, we need to check if
|
|
575
|
-
// the command exists and emit an "error" instead
|
|
576
|
-
// See https://github.com/IndigoUnited/node-cross-spawn/issues/16
|
|
577
|
-
if (name === 'exit') {
|
|
578
|
-
const err = verifyENOENT(arg1, parsed);
|
|
579
|
-
|
|
580
|
-
if (err) {
|
|
581
|
-
return originalEmit.call(cp, 'error', err);
|
|
582
|
-
}
|
|
583
|
-
}
|
|
584
|
-
|
|
585
|
-
return originalEmit.apply(cp, arguments); // eslint-disable-line prefer-rest-params
|
|
586
|
-
};
|
|
587
|
-
}
|
|
588
|
-
|
|
589
|
-
function verifyENOENT(status, parsed) {
|
|
590
|
-
if (isWin$1 && status === 1 && !parsed.file) {
|
|
591
|
-
return notFoundError(parsed.original, 'spawn');
|
|
592
|
-
}
|
|
593
|
-
|
|
594
|
-
return null;
|
|
595
|
-
}
|
|
596
|
-
|
|
597
|
-
function verifyENOENTSync(status, parsed) {
|
|
598
|
-
if (isWin$1 && status === 1 && !parsed.file) {
|
|
599
|
-
return notFoundError(parsed.original, 'spawnSync');
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
return null;
|
|
603
|
-
}
|
|
604
|
-
|
|
605
|
-
var enoent$1 = {
|
|
606
|
-
hookChildProcess,
|
|
607
|
-
verifyENOENT,
|
|
608
|
-
verifyENOENTSync,
|
|
609
|
-
notFoundError,
|
|
610
|
-
};
|
|
611
|
-
|
|
612
|
-
const cp = require$$0;
|
|
613
|
-
const parse = parse_1;
|
|
614
|
-
const enoent = enoent$1;
|
|
615
|
-
|
|
616
|
-
function spawn(command, args, options) {
|
|
617
|
-
// Parse the arguments
|
|
618
|
-
const parsed = parse(command, args, options);
|
|
619
|
-
|
|
620
|
-
// Spawn the child process
|
|
621
|
-
const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);
|
|
622
|
-
|
|
623
|
-
// Hook into child process "exit" event to emit an error if the command
|
|
624
|
-
// does not exists, see: https://github.com/IndigoUnited/node-cross-spawn/issues/16
|
|
625
|
-
enoent.hookChildProcess(spawned, parsed);
|
|
626
|
-
|
|
627
|
-
return spawned;
|
|
628
|
-
}
|
|
629
|
-
|
|
630
|
-
function spawnSync(command, args, options) {
|
|
631
|
-
// Parse the arguments
|
|
632
|
-
const parsed = parse(command, args, options);
|
|
633
|
-
|
|
634
|
-
// Spawn the child process
|
|
635
|
-
const result = cp.spawnSync(parsed.command, parsed.args, parsed.options);
|
|
636
|
-
|
|
637
|
-
// Analyze if the command does not exist, see: https://github.com/IndigoUnited/node-cross-spawn/issues/16
|
|
638
|
-
result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
|
|
639
|
-
|
|
640
|
-
return result;
|
|
641
|
-
}
|
|
642
|
-
|
|
643
|
-
crossSpawn$1.exports = spawn;
|
|
644
|
-
crossSpawn$1.exports.spawn = spawn;
|
|
645
|
-
crossSpawn$1.exports.sync = spawnSync;
|
|
646
|
-
|
|
647
|
-
crossSpawn$1.exports._parse = parse;
|
|
648
|
-
crossSpawn$1.exports._enoent = enoent;
|
|
649
|
-
|
|
650
|
-
var crossSpawnExports = crossSpawn$1.exports;
|
|
651
|
-
var crossSpawn = /*@__PURE__*/getDefaultExportFromCjs(crossSpawnExports);
|
|
652
|
-
|
|
653
|
-
function stripFinalNewline(input) {
|
|
654
|
-
const LF = typeof input === 'string' ? '\n' : '\n'.charCodeAt();
|
|
655
|
-
const CR = typeof input === 'string' ? '\r' : '\r'.charCodeAt();
|
|
656
|
-
|
|
657
|
-
if (input[input.length - 1] === LF) {
|
|
658
|
-
input = input.slice(0, -1);
|
|
659
|
-
}
|
|
660
|
-
|
|
661
|
-
if (input[input.length - 1] === CR) {
|
|
662
|
-
input = input.slice(0, -1);
|
|
663
|
-
}
|
|
664
|
-
|
|
665
|
-
return input;
|
|
666
|
-
}
|
|
667
|
-
|
|
668
|
-
function pathKey(options = {}) {
|
|
669
|
-
const {
|
|
670
|
-
env = process.env,
|
|
671
|
-
platform = process.platform
|
|
672
|
-
} = options;
|
|
673
|
-
|
|
674
|
-
if (platform !== 'win32') {
|
|
675
|
-
return 'PATH';
|
|
676
|
-
}
|
|
677
|
-
|
|
678
|
-
return Object.keys(env).reverse().find(key => key.toUpperCase() === 'PATH') || 'Path';
|
|
679
|
-
}
|
|
680
|
-
|
|
681
|
-
function npmRunPath(options = {}) {
|
|
682
|
-
const {
|
|
683
|
-
cwd = process$2.cwd(),
|
|
684
|
-
path: path_ = process$2.env[pathKey()],
|
|
685
|
-
execPath = process$2.execPath,
|
|
686
|
-
} = options;
|
|
687
|
-
|
|
688
|
-
let previous;
|
|
689
|
-
const cwdString = cwd instanceof URL ? url.fileURLToPath(cwd) : cwd;
|
|
690
|
-
let cwdPath = path$3.resolve(cwdString);
|
|
691
|
-
const result = [];
|
|
692
|
-
|
|
693
|
-
while (previous !== cwdPath) {
|
|
694
|
-
result.push(path$3.join(cwdPath, 'node_modules/.bin'));
|
|
695
|
-
previous = cwdPath;
|
|
696
|
-
cwdPath = path$3.resolve(cwdPath, '..');
|
|
697
|
-
}
|
|
698
|
-
|
|
699
|
-
// Ensure the running `node` binary is used.
|
|
700
|
-
result.push(path$3.resolve(cwdString, execPath, '..'));
|
|
701
|
-
|
|
702
|
-
return [...result, path_].join(path$3.delimiter);
|
|
703
|
-
}
|
|
704
|
-
|
|
705
|
-
function npmRunPathEnv({env = process$2.env, ...options} = {}) {
|
|
706
|
-
env = {...env};
|
|
707
|
-
|
|
708
|
-
const path = pathKey({env});
|
|
709
|
-
options.path = env[path];
|
|
710
|
-
env[path] = npmRunPath(options);
|
|
711
|
-
|
|
712
|
-
return env;
|
|
713
|
-
}
|
|
714
|
-
|
|
715
|
-
const copyProperty = (to, from, property, ignoreNonConfigurable) => {
|
|
716
|
-
// `Function#length` should reflect the parameters of `to` not `from` since we keep its body.
|
|
717
|
-
// `Function#prototype` is non-writable and non-configurable so can never be modified.
|
|
718
|
-
if (property === 'length' || property === 'prototype') {
|
|
719
|
-
return;
|
|
720
|
-
}
|
|
721
|
-
|
|
722
|
-
// `Function#arguments` and `Function#caller` should not be copied. They were reported to be present in `Reflect.ownKeys` for some devices in React Native (#41), so we explicitly ignore them here.
|
|
723
|
-
if (property === 'arguments' || property === 'caller') {
|
|
724
|
-
return;
|
|
725
|
-
}
|
|
726
|
-
|
|
727
|
-
const toDescriptor = Object.getOwnPropertyDescriptor(to, property);
|
|
728
|
-
const fromDescriptor = Object.getOwnPropertyDescriptor(from, property);
|
|
729
|
-
|
|
730
|
-
if (!canCopyProperty(toDescriptor, fromDescriptor) && ignoreNonConfigurable) {
|
|
731
|
-
return;
|
|
732
|
-
}
|
|
733
|
-
|
|
734
|
-
Object.defineProperty(to, property, fromDescriptor);
|
|
735
|
-
};
|
|
736
|
-
|
|
737
|
-
// `Object.defineProperty()` throws if the property exists, is not configurable and either:
|
|
738
|
-
// - one its descriptors is changed
|
|
739
|
-
// - it is non-writable and its value is changed
|
|
740
|
-
const canCopyProperty = function (toDescriptor, fromDescriptor) {
|
|
741
|
-
return toDescriptor === undefined || toDescriptor.configurable || (
|
|
742
|
-
toDescriptor.writable === fromDescriptor.writable &&
|
|
743
|
-
toDescriptor.enumerable === fromDescriptor.enumerable &&
|
|
744
|
-
toDescriptor.configurable === fromDescriptor.configurable &&
|
|
745
|
-
(toDescriptor.writable || toDescriptor.value === fromDescriptor.value)
|
|
746
|
-
);
|
|
747
|
-
};
|
|
748
|
-
|
|
749
|
-
const changePrototype = (to, from) => {
|
|
750
|
-
const fromPrototype = Object.getPrototypeOf(from);
|
|
751
|
-
if (fromPrototype === Object.getPrototypeOf(to)) {
|
|
752
|
-
return;
|
|
753
|
-
}
|
|
754
|
-
|
|
755
|
-
Object.setPrototypeOf(to, fromPrototype);
|
|
756
|
-
};
|
|
757
|
-
|
|
758
|
-
const wrappedToString = (withName, fromBody) => `/* Wrapped ${withName}*/\n${fromBody}`;
|
|
759
|
-
|
|
760
|
-
const toStringDescriptor = Object.getOwnPropertyDescriptor(Function.prototype, 'toString');
|
|
761
|
-
const toStringName = Object.getOwnPropertyDescriptor(Function.prototype.toString, 'name');
|
|
762
|
-
|
|
763
|
-
// We call `from.toString()` early (not lazily) to ensure `from` can be garbage collected.
|
|
764
|
-
// We use `bind()` instead of a closure for the same reason.
|
|
765
|
-
// Calling `from.toString()` early also allows caching it in case `to.toString()` is called several times.
|
|
766
|
-
const changeToString = (to, from, name) => {
|
|
767
|
-
const withName = name === '' ? '' : `with ${name.trim()}() `;
|
|
768
|
-
const newToString = wrappedToString.bind(null, withName, from.toString());
|
|
769
|
-
// Ensure `to.toString.toString` is non-enumerable and has the same `same`
|
|
770
|
-
Object.defineProperty(newToString, 'name', toStringName);
|
|
771
|
-
Object.defineProperty(to, 'toString', {...toStringDescriptor, value: newToString});
|
|
772
|
-
};
|
|
773
|
-
|
|
774
|
-
function mimicFunction(to, from, {ignoreNonConfigurable = false} = {}) {
|
|
775
|
-
const {name} = to;
|
|
776
|
-
|
|
777
|
-
for (const property of Reflect.ownKeys(from)) {
|
|
778
|
-
copyProperty(to, from, property, ignoreNonConfigurable);
|
|
779
|
-
}
|
|
780
|
-
|
|
781
|
-
changePrototype(to, from);
|
|
782
|
-
changeToString(to, from, name);
|
|
783
|
-
|
|
784
|
-
return to;
|
|
785
|
-
}
|
|
786
|
-
|
|
787
|
-
const calledFunctions = new WeakMap();
|
|
788
|
-
|
|
789
|
-
const onetime = (function_, options = {}) => {
|
|
790
|
-
if (typeof function_ !== 'function') {
|
|
791
|
-
throw new TypeError('Expected a function');
|
|
792
|
-
}
|
|
793
|
-
|
|
794
|
-
let returnValue;
|
|
795
|
-
let callCount = 0;
|
|
796
|
-
const functionName = function_.displayName || function_.name || '<anonymous>';
|
|
797
|
-
|
|
798
|
-
const onetime = function (...arguments_) {
|
|
799
|
-
calledFunctions.set(onetime, ++callCount);
|
|
800
|
-
|
|
801
|
-
if (callCount === 1) {
|
|
802
|
-
returnValue = function_.apply(this, arguments_);
|
|
803
|
-
function_ = null;
|
|
804
|
-
} else if (options.throw === true) {
|
|
805
|
-
throw new Error(`Function \`${functionName}\` can only be called once`);
|
|
806
|
-
}
|
|
807
|
-
|
|
808
|
-
return returnValue;
|
|
809
|
-
};
|
|
810
|
-
|
|
811
|
-
mimicFunction(onetime, function_);
|
|
812
|
-
calledFunctions.set(onetime, callCount);
|
|
813
|
-
|
|
814
|
-
return onetime;
|
|
815
|
-
};
|
|
816
|
-
|
|
817
|
-
onetime.callCount = function_ => {
|
|
818
|
-
if (!calledFunctions.has(function_)) {
|
|
819
|
-
throw new Error(`The given function \`${function_.name}\` is not wrapped by the \`onetime\` package`);
|
|
820
|
-
}
|
|
821
|
-
|
|
822
|
-
return calledFunctions.get(function_);
|
|
823
|
-
};
|
|
824
|
-
|
|
825
|
-
const getRealtimeSignals=function(){
|
|
826
|
-
const length=SIGRTMAX-SIGRTMIN+1;
|
|
827
|
-
return Array.from({length},getRealtimeSignal);
|
|
828
|
-
};
|
|
829
|
-
|
|
830
|
-
const getRealtimeSignal=function(value,index){
|
|
831
|
-
return {
|
|
832
|
-
name:`SIGRT${index+1}`,
|
|
833
|
-
number:SIGRTMIN+index,
|
|
834
|
-
action:"terminate",
|
|
835
|
-
description:"Application-specific signal (realtime)",
|
|
836
|
-
standard:"posix"};
|
|
837
|
-
|
|
838
|
-
};
|
|
839
|
-
|
|
840
|
-
const SIGRTMIN=34;
|
|
841
|
-
const SIGRTMAX=64;
|
|
842
|
-
|
|
843
|
-
const SIGNALS=[
|
|
844
|
-
{
|
|
845
|
-
name:"SIGHUP",
|
|
846
|
-
number:1,
|
|
847
|
-
action:"terminate",
|
|
848
|
-
description:"Terminal closed",
|
|
849
|
-
standard:"posix"},
|
|
850
|
-
|
|
851
|
-
{
|
|
852
|
-
name:"SIGINT",
|
|
853
|
-
number:2,
|
|
854
|
-
action:"terminate",
|
|
855
|
-
description:"User interruption with CTRL-C",
|
|
856
|
-
standard:"ansi"},
|
|
857
|
-
|
|
858
|
-
{
|
|
859
|
-
name:"SIGQUIT",
|
|
860
|
-
number:3,
|
|
861
|
-
action:"core",
|
|
862
|
-
description:"User interruption with CTRL-\\",
|
|
863
|
-
standard:"posix"},
|
|
864
|
-
|
|
865
|
-
{
|
|
866
|
-
name:"SIGILL",
|
|
867
|
-
number:4,
|
|
868
|
-
action:"core",
|
|
869
|
-
description:"Invalid machine instruction",
|
|
870
|
-
standard:"ansi"},
|
|
871
|
-
|
|
872
|
-
{
|
|
873
|
-
name:"SIGTRAP",
|
|
874
|
-
number:5,
|
|
875
|
-
action:"core",
|
|
876
|
-
description:"Debugger breakpoint",
|
|
877
|
-
standard:"posix"},
|
|
878
|
-
|
|
879
|
-
{
|
|
880
|
-
name:"SIGABRT",
|
|
881
|
-
number:6,
|
|
882
|
-
action:"core",
|
|
883
|
-
description:"Aborted",
|
|
884
|
-
standard:"ansi"},
|
|
885
|
-
|
|
886
|
-
{
|
|
887
|
-
name:"SIGIOT",
|
|
888
|
-
number:6,
|
|
889
|
-
action:"core",
|
|
890
|
-
description:"Aborted",
|
|
891
|
-
standard:"bsd"},
|
|
892
|
-
|
|
893
|
-
{
|
|
894
|
-
name:"SIGBUS",
|
|
895
|
-
number:7,
|
|
896
|
-
action:"core",
|
|
897
|
-
description:
|
|
898
|
-
"Bus error due to misaligned, non-existing address or paging error",
|
|
899
|
-
standard:"bsd"},
|
|
900
|
-
|
|
901
|
-
{
|
|
902
|
-
name:"SIGEMT",
|
|
903
|
-
number:7,
|
|
904
|
-
action:"terminate",
|
|
905
|
-
description:"Command should be emulated but is not implemented",
|
|
906
|
-
standard:"other"},
|
|
907
|
-
|
|
908
|
-
{
|
|
909
|
-
name:"SIGFPE",
|
|
910
|
-
number:8,
|
|
911
|
-
action:"core",
|
|
912
|
-
description:"Floating point arithmetic error",
|
|
913
|
-
standard:"ansi"},
|
|
914
|
-
|
|
915
|
-
{
|
|
916
|
-
name:"SIGKILL",
|
|
917
|
-
number:9,
|
|
918
|
-
action:"terminate",
|
|
919
|
-
description:"Forced termination",
|
|
920
|
-
standard:"posix",
|
|
921
|
-
forced:true},
|
|
922
|
-
|
|
923
|
-
{
|
|
924
|
-
name:"SIGUSR1",
|
|
925
|
-
number:10,
|
|
926
|
-
action:"terminate",
|
|
927
|
-
description:"Application-specific signal",
|
|
928
|
-
standard:"posix"},
|
|
929
|
-
|
|
930
|
-
{
|
|
931
|
-
name:"SIGSEGV",
|
|
932
|
-
number:11,
|
|
933
|
-
action:"core",
|
|
934
|
-
description:"Segmentation fault",
|
|
935
|
-
standard:"ansi"},
|
|
936
|
-
|
|
937
|
-
{
|
|
938
|
-
name:"SIGUSR2",
|
|
939
|
-
number:12,
|
|
940
|
-
action:"terminate",
|
|
941
|
-
description:"Application-specific signal",
|
|
942
|
-
standard:"posix"},
|
|
943
|
-
|
|
944
|
-
{
|
|
945
|
-
name:"SIGPIPE",
|
|
946
|
-
number:13,
|
|
947
|
-
action:"terminate",
|
|
948
|
-
description:"Broken pipe or socket",
|
|
949
|
-
standard:"posix"},
|
|
950
|
-
|
|
951
|
-
{
|
|
952
|
-
name:"SIGALRM",
|
|
953
|
-
number:14,
|
|
954
|
-
action:"terminate",
|
|
955
|
-
description:"Timeout or timer",
|
|
956
|
-
standard:"posix"},
|
|
957
|
-
|
|
958
|
-
{
|
|
959
|
-
name:"SIGTERM",
|
|
960
|
-
number:15,
|
|
961
|
-
action:"terminate",
|
|
962
|
-
description:"Termination",
|
|
963
|
-
standard:"ansi"},
|
|
964
|
-
|
|
965
|
-
{
|
|
966
|
-
name:"SIGSTKFLT",
|
|
967
|
-
number:16,
|
|
968
|
-
action:"terminate",
|
|
969
|
-
description:"Stack is empty or overflowed",
|
|
970
|
-
standard:"other"},
|
|
971
|
-
|
|
972
|
-
{
|
|
973
|
-
name:"SIGCHLD",
|
|
974
|
-
number:17,
|
|
975
|
-
action:"ignore",
|
|
976
|
-
description:"Child process terminated, paused or unpaused",
|
|
977
|
-
standard:"posix"},
|
|
978
|
-
|
|
979
|
-
{
|
|
980
|
-
name:"SIGCLD",
|
|
981
|
-
number:17,
|
|
982
|
-
action:"ignore",
|
|
983
|
-
description:"Child process terminated, paused or unpaused",
|
|
984
|
-
standard:"other"},
|
|
985
|
-
|
|
986
|
-
{
|
|
987
|
-
name:"SIGCONT",
|
|
988
|
-
number:18,
|
|
989
|
-
action:"unpause",
|
|
990
|
-
description:"Unpaused",
|
|
991
|
-
standard:"posix",
|
|
992
|
-
forced:true},
|
|
993
|
-
|
|
994
|
-
{
|
|
995
|
-
name:"SIGSTOP",
|
|
996
|
-
number:19,
|
|
997
|
-
action:"pause",
|
|
998
|
-
description:"Paused",
|
|
999
|
-
standard:"posix",
|
|
1000
|
-
forced:true},
|
|
1001
|
-
|
|
1002
|
-
{
|
|
1003
|
-
name:"SIGTSTP",
|
|
1004
|
-
number:20,
|
|
1005
|
-
action:"pause",
|
|
1006
|
-
description:"Paused using CTRL-Z or \"suspend\"",
|
|
1007
|
-
standard:"posix"},
|
|
1008
|
-
|
|
1009
|
-
{
|
|
1010
|
-
name:"SIGTTIN",
|
|
1011
|
-
number:21,
|
|
1012
|
-
action:"pause",
|
|
1013
|
-
description:"Background process cannot read terminal input",
|
|
1014
|
-
standard:"posix"},
|
|
1015
|
-
|
|
1016
|
-
{
|
|
1017
|
-
name:"SIGBREAK",
|
|
1018
|
-
number:21,
|
|
1019
|
-
action:"terminate",
|
|
1020
|
-
description:"User interruption with CTRL-BREAK",
|
|
1021
|
-
standard:"other"},
|
|
1022
|
-
|
|
1023
|
-
{
|
|
1024
|
-
name:"SIGTTOU",
|
|
1025
|
-
number:22,
|
|
1026
|
-
action:"pause",
|
|
1027
|
-
description:"Background process cannot write to terminal output",
|
|
1028
|
-
standard:"posix"},
|
|
1029
|
-
|
|
1030
|
-
{
|
|
1031
|
-
name:"SIGURG",
|
|
1032
|
-
number:23,
|
|
1033
|
-
action:"ignore",
|
|
1034
|
-
description:"Socket received out-of-band data",
|
|
1035
|
-
standard:"bsd"},
|
|
1036
|
-
|
|
1037
|
-
{
|
|
1038
|
-
name:"SIGXCPU",
|
|
1039
|
-
number:24,
|
|
1040
|
-
action:"core",
|
|
1041
|
-
description:"Process timed out",
|
|
1042
|
-
standard:"bsd"},
|
|
1043
|
-
|
|
1044
|
-
{
|
|
1045
|
-
name:"SIGXFSZ",
|
|
1046
|
-
number:25,
|
|
1047
|
-
action:"core",
|
|
1048
|
-
description:"File too big",
|
|
1049
|
-
standard:"bsd"},
|
|
1050
|
-
|
|
1051
|
-
{
|
|
1052
|
-
name:"SIGVTALRM",
|
|
1053
|
-
number:26,
|
|
1054
|
-
action:"terminate",
|
|
1055
|
-
description:"Timeout or timer",
|
|
1056
|
-
standard:"bsd"},
|
|
1057
|
-
|
|
1058
|
-
{
|
|
1059
|
-
name:"SIGPROF",
|
|
1060
|
-
number:27,
|
|
1061
|
-
action:"terminate",
|
|
1062
|
-
description:"Timeout or timer",
|
|
1063
|
-
standard:"bsd"},
|
|
1064
|
-
|
|
1065
|
-
{
|
|
1066
|
-
name:"SIGWINCH",
|
|
1067
|
-
number:28,
|
|
1068
|
-
action:"ignore",
|
|
1069
|
-
description:"Terminal window size changed",
|
|
1070
|
-
standard:"bsd"},
|
|
1071
|
-
|
|
1072
|
-
{
|
|
1073
|
-
name:"SIGIO",
|
|
1074
|
-
number:29,
|
|
1075
|
-
action:"terminate",
|
|
1076
|
-
description:"I/O is available",
|
|
1077
|
-
standard:"other"},
|
|
1078
|
-
|
|
1079
|
-
{
|
|
1080
|
-
name:"SIGPOLL",
|
|
1081
|
-
number:29,
|
|
1082
|
-
action:"terminate",
|
|
1083
|
-
description:"Watched event",
|
|
1084
|
-
standard:"other"},
|
|
1085
|
-
|
|
1086
|
-
{
|
|
1087
|
-
name:"SIGINFO",
|
|
1088
|
-
number:29,
|
|
1089
|
-
action:"ignore",
|
|
1090
|
-
description:"Request for process information",
|
|
1091
|
-
standard:"other"},
|
|
1092
|
-
|
|
1093
|
-
{
|
|
1094
|
-
name:"SIGPWR",
|
|
1095
|
-
number:30,
|
|
1096
|
-
action:"terminate",
|
|
1097
|
-
description:"Device running out of power",
|
|
1098
|
-
standard:"systemv"},
|
|
1099
|
-
|
|
1100
|
-
{
|
|
1101
|
-
name:"SIGSYS",
|
|
1102
|
-
number:31,
|
|
1103
|
-
action:"core",
|
|
1104
|
-
description:"Invalid system call",
|
|
1105
|
-
standard:"other"},
|
|
1106
|
-
|
|
1107
|
-
{
|
|
1108
|
-
name:"SIGUNUSED",
|
|
1109
|
-
number:31,
|
|
1110
|
-
action:"terminate",
|
|
1111
|
-
description:"Invalid system call",
|
|
1112
|
-
standard:"other"}];
|
|
1113
|
-
|
|
1114
|
-
const getSignals=function(){
|
|
1115
|
-
const realtimeSignals=getRealtimeSignals();
|
|
1116
|
-
const signals=[...SIGNALS,...realtimeSignals].map(normalizeSignal);
|
|
1117
|
-
return signals;
|
|
1118
|
-
};
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
const normalizeSignal=function({
|
|
1127
|
-
name,
|
|
1128
|
-
number:defaultNumber,
|
|
1129
|
-
description,
|
|
1130
|
-
action,
|
|
1131
|
-
forced=false,
|
|
1132
|
-
standard})
|
|
1133
|
-
{
|
|
1134
|
-
const{
|
|
1135
|
-
signals:{[name]:constantSignal}}=
|
|
1136
|
-
constants;
|
|
1137
|
-
const supported=constantSignal!==undefined;
|
|
1138
|
-
const number=supported?constantSignal:defaultNumber;
|
|
1139
|
-
return {name,number,description,supported,action,forced,standard};
|
|
1140
|
-
};
|
|
1141
|
-
|
|
1142
|
-
const getSignalsByName=function(){
|
|
1143
|
-
const signals=getSignals();
|
|
1144
|
-
return Object.fromEntries(signals.map(getSignalByName));
|
|
1145
|
-
};
|
|
1146
|
-
|
|
1147
|
-
const getSignalByName=function({
|
|
1148
|
-
name,
|
|
1149
|
-
number,
|
|
1150
|
-
description,
|
|
1151
|
-
supported,
|
|
1152
|
-
action,
|
|
1153
|
-
forced,
|
|
1154
|
-
standard})
|
|
1155
|
-
{
|
|
1156
|
-
return [
|
|
1157
|
-
name,
|
|
1158
|
-
{name,number,description,supported,action,forced,standard}];
|
|
1159
|
-
|
|
1160
|
-
};
|
|
1161
|
-
|
|
1162
|
-
const signalsByName=getSignalsByName();
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
const getSignalsByNumber=function(){
|
|
1168
|
-
const signals=getSignals();
|
|
1169
|
-
const length=SIGRTMAX+1;
|
|
1170
|
-
const signalsA=Array.from({length},(value,number)=>
|
|
1171
|
-
getSignalByNumber(number,signals));
|
|
1172
|
-
|
|
1173
|
-
return Object.assign({},...signalsA);
|
|
1174
|
-
};
|
|
1175
|
-
|
|
1176
|
-
const getSignalByNumber=function(number,signals){
|
|
1177
|
-
const signal=findSignalByNumber(number,signals);
|
|
1178
|
-
|
|
1179
|
-
if(signal===undefined){
|
|
1180
|
-
return {};
|
|
1181
|
-
}
|
|
1182
|
-
|
|
1183
|
-
const{name,description,supported,action,forced,standard}=signal;
|
|
1184
|
-
return {
|
|
1185
|
-
[number]:{
|
|
1186
|
-
name,
|
|
1187
|
-
number,
|
|
1188
|
-
description,
|
|
1189
|
-
supported,
|
|
1190
|
-
action,
|
|
1191
|
-
forced,
|
|
1192
|
-
standard}};
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
};
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
const findSignalByNumber=function(number,signals){
|
|
1200
|
-
const signal=signals.find(({name})=>constants.signals[name]===number);
|
|
1201
|
-
|
|
1202
|
-
if(signal!==undefined){
|
|
1203
|
-
return signal;
|
|
1204
|
-
}
|
|
1205
|
-
|
|
1206
|
-
return signals.find((signalA)=>signalA.number===number);
|
|
1207
|
-
};
|
|
1208
|
-
|
|
1209
|
-
getSignalsByNumber();
|
|
1210
|
-
|
|
1211
|
-
const getErrorPrefix = ({timedOut, timeout, errorCode, signal, signalDescription, exitCode, isCanceled}) => {
|
|
1212
|
-
if (timedOut) {
|
|
1213
|
-
return `timed out after ${timeout} milliseconds`;
|
|
1214
|
-
}
|
|
1215
|
-
|
|
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
|
-
};
|
|
1410
|
-
|
|
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);
|
|
1421
|
-
|
|
1422
|
-
var EE = require$$2;
|
|
1423
|
-
/* istanbul ignore if */
|
|
1424
|
-
if (typeof EE !== 'function') {
|
|
1425
|
-
EE = EE.EventEmitter;
|
|
1426
|
-
}
|
|
1427
|
-
|
|
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
|
-
}
|
|
1436
|
-
|
|
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
|
-
}
|
|
1445
|
-
|
|
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');
|
|
1452
|
-
|
|
1453
|
-
if (loaded === false) {
|
|
1454
|
-
load();
|
|
1455
|
-
}
|
|
1456
|
-
|
|
1457
|
-
var ev = 'exit';
|
|
1458
|
-
if (opts && opts.alwaysLast) {
|
|
1459
|
-
ev = 'afterexit';
|
|
1460
|
-
}
|
|
1461
|
-
|
|
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);
|
|
1470
|
-
|
|
1471
|
-
return remove
|
|
1472
|
-
};
|
|
1473
|
-
|
|
1474
|
-
var unload = function unload () {
|
|
1475
|
-
if (!loaded || !processOk(commonjsGlobal.process)) {
|
|
1476
|
-
return
|
|
1477
|
-
}
|
|
1478
|
-
loaded = false;
|
|
1479
|
-
|
|
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;
|
|
1490
|
-
|
|
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
|
-
};
|
|
1499
|
-
|
|
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
|
-
});
|
|
1529
|
-
|
|
1530
|
-
signalExit$1.exports.signals = function () {
|
|
1531
|
-
return signals
|
|
1532
|
-
};
|
|
1533
|
-
|
|
1534
|
-
var loaded = false;
|
|
1535
|
-
|
|
1536
|
-
var load = function load () {
|
|
1537
|
-
if (loaded || !processOk(commonjsGlobal.process)) {
|
|
1538
|
-
return
|
|
1539
|
-
}
|
|
1540
|
-
loaded = true;
|
|
1541
|
-
|
|
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;
|
|
1547
|
-
|
|
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
|
-
});
|
|
1556
|
-
|
|
1557
|
-
process$1.emit = processEmit;
|
|
1558
|
-
process$1.reallyExit = processReallyExit;
|
|
1559
|
-
};
|
|
1560
|
-
signalExit$1.exports.load = load;
|
|
1561
|
-
|
|
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
|
-
};
|
|
1575
|
-
|
|
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
|
-
}
|
|
1595
|
-
|
|
1596
|
-
var signalExitExports = signalExit$1.exports;
|
|
1597
|
-
var signalExit = /*@__PURE__*/getDefaultExportFromCjs(signalExitExports);
|
|
1598
|
-
|
|
1599
|
-
const DEFAULT_FORCE_KILL_TIMEOUT = 1000 * 5;
|
|
1600
|
-
|
|
1601
|
-
// Monkey-patches `childProcess.kill()` to add `forceKillAfterTimeout` behavior
|
|
1602
|
-
const spawnedKill = (kill, signal = 'SIGTERM', options = {}) => {
|
|
1603
|
-
const killResult = kill(signal);
|
|
1604
|
-
setKillTimeout(kill, signal, options, killResult);
|
|
1605
|
-
return killResult;
|
|
1606
|
-
};
|
|
1607
|
-
|
|
1608
|
-
const setKillTimeout = (kill, signal, options, killResult) => {
|
|
1609
|
-
if (!shouldForceKill(signal, options, killResult)) {
|
|
1610
|
-
return;
|
|
1611
|
-
}
|
|
1612
|
-
|
|
1613
|
-
const timeout = getForceKillAfterTimeout(options);
|
|
1614
|
-
const t = setTimeout(() => {
|
|
1615
|
-
kill('SIGKILL');
|
|
1616
|
-
}, timeout);
|
|
1617
|
-
|
|
1618
|
-
// Guarded because there's no `.unref()` when `execa` is used in the renderer
|
|
1619
|
-
// process in Electron. This cannot be tested since we don't run tests in
|
|
1620
|
-
// Electron.
|
|
1621
|
-
// istanbul ignore else
|
|
1622
|
-
if (t.unref) {
|
|
1623
|
-
t.unref();
|
|
1624
|
-
}
|
|
1625
|
-
};
|
|
1626
|
-
|
|
1627
|
-
const shouldForceKill = (signal, {forceKillAfterTimeout}, killResult) => isSigterm(signal) && forceKillAfterTimeout !== false && killResult;
|
|
1628
|
-
|
|
1629
|
-
const isSigterm = signal => signal === nodeos__default.constants.signals.SIGTERM
|
|
1630
|
-
|| (typeof signal === 'string' && signal.toUpperCase() === 'SIGTERM');
|
|
1631
|
-
|
|
1632
|
-
const getForceKillAfterTimeout = ({forceKillAfterTimeout = true}) => {
|
|
1633
|
-
if (forceKillAfterTimeout === true) {
|
|
1634
|
-
return DEFAULT_FORCE_KILL_TIMEOUT;
|
|
1635
|
-
}
|
|
1636
|
-
|
|
1637
|
-
if (!Number.isFinite(forceKillAfterTimeout) || forceKillAfterTimeout < 0) {
|
|
1638
|
-
throw new TypeError(`Expected the \`forceKillAfterTimeout\` option to be a non-negative integer, got \`${forceKillAfterTimeout}\` (${typeof forceKillAfterTimeout})`);
|
|
1639
|
-
}
|
|
1640
|
-
|
|
1641
|
-
return forceKillAfterTimeout;
|
|
1642
|
-
};
|
|
1643
|
-
|
|
1644
|
-
// `childProcess.cancel()`
|
|
1645
|
-
const spawnedCancel = (spawned, context) => {
|
|
1646
|
-
const killResult = spawned.kill();
|
|
1647
|
-
|
|
1648
|
-
if (killResult) {
|
|
1649
|
-
context.isCanceled = true;
|
|
1650
|
-
}
|
|
1651
|
-
};
|
|
1652
|
-
|
|
1653
|
-
const timeoutKill = (spawned, signal, reject) => {
|
|
1654
|
-
spawned.kill(signal);
|
|
1655
|
-
reject(Object.assign(new Error('Timed out'), {timedOut: true, signal}));
|
|
1656
|
-
};
|
|
1657
|
-
|
|
1658
|
-
// `timeout` option handling
|
|
1659
|
-
const setupTimeout = (spawned, {timeout, killSignal = 'SIGTERM'}, spawnedPromise) => {
|
|
1660
|
-
if (timeout === 0 || timeout === undefined) {
|
|
1661
|
-
return spawnedPromise;
|
|
1662
|
-
}
|
|
1663
|
-
|
|
1664
|
-
let timeoutId;
|
|
1665
|
-
const timeoutPromise = new Promise((resolve, reject) => {
|
|
1666
|
-
timeoutId = setTimeout(() => {
|
|
1667
|
-
timeoutKill(spawned, killSignal, reject);
|
|
1668
|
-
}, timeout);
|
|
1669
|
-
});
|
|
1670
|
-
|
|
1671
|
-
const safeSpawnedPromise = spawnedPromise.finally(() => {
|
|
1672
|
-
clearTimeout(timeoutId);
|
|
1673
|
-
});
|
|
1674
|
-
|
|
1675
|
-
return Promise.race([timeoutPromise, safeSpawnedPromise]);
|
|
1676
|
-
};
|
|
1677
|
-
|
|
1678
|
-
const validateTimeout = ({timeout}) => {
|
|
1679
|
-
if (timeout !== undefined && (!Number.isFinite(timeout) || timeout < 0)) {
|
|
1680
|
-
throw new TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${timeout}\` (${typeof timeout})`);
|
|
1681
|
-
}
|
|
1682
|
-
};
|
|
1683
|
-
|
|
1684
|
-
// `cleanup` option handling
|
|
1685
|
-
const setExitHandler = async (spawned, {cleanup, detached}, timedPromise) => {
|
|
1686
|
-
if (!cleanup || detached) {
|
|
1687
|
-
return timedPromise;
|
|
1688
|
-
}
|
|
1689
|
-
|
|
1690
|
-
const removeExitHandler = signalExit(() => {
|
|
1691
|
-
spawned.kill();
|
|
1692
|
-
});
|
|
1693
|
-
|
|
1694
|
-
return timedPromise.finally(() => {
|
|
1695
|
-
removeExitHandler();
|
|
1696
|
-
});
|
|
1697
|
-
};
|
|
1698
|
-
|
|
1699
|
-
function isStream(stream) {
|
|
1700
|
-
return stream !== null
|
|
1701
|
-
&& typeof stream === 'object'
|
|
1702
|
-
&& typeof stream.pipe === 'function';
|
|
1703
|
-
}
|
|
1704
|
-
|
|
1705
|
-
function isWritableStream(stream) {
|
|
1706
|
-
return isStream(stream)
|
|
1707
|
-
&& stream.writable !== false
|
|
1708
|
-
&& typeof stream._write === 'function'
|
|
1709
|
-
&& typeof stream._writableState === 'object';
|
|
1710
|
-
}
|
|
1711
|
-
|
|
1712
|
-
const isExecaChildProcess = target => target instanceof ChildProcess && typeof target.then === 'function';
|
|
1713
|
-
|
|
1714
|
-
const pipeToTarget = (spawned, streamName, target) => {
|
|
1715
|
-
if (typeof target === 'string') {
|
|
1716
|
-
spawned[streamName].pipe(createWriteStream(target));
|
|
1717
|
-
return spawned;
|
|
1718
|
-
}
|
|
1719
|
-
|
|
1720
|
-
if (isWritableStream(target)) {
|
|
1721
|
-
spawned[streamName].pipe(target);
|
|
1722
|
-
return spawned;
|
|
1723
|
-
}
|
|
1724
|
-
|
|
1725
|
-
if (!isExecaChildProcess(target)) {
|
|
1726
|
-
throw new TypeError('The second argument must be a string, a stream or an Execa child process.');
|
|
1727
|
-
}
|
|
1728
|
-
|
|
1729
|
-
if (!isWritableStream(target.stdin)) {
|
|
1730
|
-
throw new TypeError('The target child process\'s stdin must be available.');
|
|
1731
|
-
}
|
|
1732
|
-
|
|
1733
|
-
spawned[streamName].pipe(target.stdin);
|
|
1734
|
-
return target;
|
|
1735
|
-
};
|
|
1736
|
-
|
|
1737
|
-
const addPipeMethods = spawned => {
|
|
1738
|
-
if (spawned.stdout !== null) {
|
|
1739
|
-
spawned.pipeStdout = pipeToTarget.bind(undefined, spawned, 'stdout');
|
|
1740
|
-
}
|
|
1741
|
-
|
|
1742
|
-
if (spawned.stderr !== null) {
|
|
1743
|
-
spawned.pipeStderr = pipeToTarget.bind(undefined, spawned, 'stderr');
|
|
1744
|
-
}
|
|
1745
|
-
|
|
1746
|
-
if (spawned.all !== undefined) {
|
|
1747
|
-
spawned.pipeAll = pipeToTarget.bind(undefined, spawned, 'all');
|
|
1748
|
-
}
|
|
1749
|
-
};
|
|
1750
|
-
|
|
1751
|
-
var getStream$2 = {exports: {}};
|
|
1752
|
-
|
|
1753
|
-
const {PassThrough: PassThroughStream} = require$$0$2;
|
|
1754
|
-
|
|
1755
|
-
var bufferStream$1 = options => {
|
|
1756
|
-
options = {...options};
|
|
1757
|
-
|
|
1758
|
-
const {array} = options;
|
|
1759
|
-
let {encoding} = options;
|
|
1760
|
-
const isBuffer = encoding === 'buffer';
|
|
1761
|
-
let objectMode = false;
|
|
1762
|
-
|
|
1763
|
-
if (array) {
|
|
1764
|
-
objectMode = !(encoding || isBuffer);
|
|
1765
|
-
} else {
|
|
1766
|
-
encoding = encoding || 'utf8';
|
|
1767
|
-
}
|
|
1768
|
-
|
|
1769
|
-
if (isBuffer) {
|
|
1770
|
-
encoding = null;
|
|
1771
|
-
}
|
|
1772
|
-
|
|
1773
|
-
const stream = new PassThroughStream({objectMode});
|
|
1774
|
-
|
|
1775
|
-
if (encoding) {
|
|
1776
|
-
stream.setEncoding(encoding);
|
|
1777
|
-
}
|
|
1778
|
-
|
|
1779
|
-
let length = 0;
|
|
1780
|
-
const chunks = [];
|
|
1781
|
-
|
|
1782
|
-
stream.on('data', chunk => {
|
|
1783
|
-
chunks.push(chunk);
|
|
1784
|
-
|
|
1785
|
-
if (objectMode) {
|
|
1786
|
-
length = chunks.length;
|
|
1787
|
-
} else {
|
|
1788
|
-
length += chunk.length;
|
|
1789
|
-
}
|
|
1790
|
-
});
|
|
1791
|
-
|
|
1792
|
-
stream.getBufferedValue = () => {
|
|
1793
|
-
if (array) {
|
|
1794
|
-
return chunks;
|
|
1795
|
-
}
|
|
1796
|
-
|
|
1797
|
-
return isBuffer ? Buffer.concat(chunks, length) : chunks.join('');
|
|
1798
|
-
};
|
|
1799
|
-
|
|
1800
|
-
stream.getBufferedLength = () => length;
|
|
1801
|
-
|
|
1802
|
-
return stream;
|
|
1803
|
-
};
|
|
1804
|
-
|
|
1805
|
-
const {constants: BufferConstants} = require$$0$4;
|
|
1806
|
-
const stream = require$$0$2;
|
|
1807
|
-
const {promisify} = require$$0$3;
|
|
1808
|
-
const bufferStream = bufferStream$1;
|
|
1809
|
-
|
|
1810
|
-
const streamPipelinePromisified = promisify(stream.pipeline);
|
|
1811
|
-
|
|
1812
|
-
class MaxBufferError extends Error {
|
|
1813
|
-
constructor() {
|
|
1814
|
-
super('maxBuffer exceeded');
|
|
1815
|
-
this.name = 'MaxBufferError';
|
|
1816
|
-
}
|
|
1817
|
-
}
|
|
1818
|
-
|
|
1819
|
-
async function getStream(inputStream, options) {
|
|
1820
|
-
if (!inputStream) {
|
|
1821
|
-
throw new Error('Expected a stream');
|
|
1822
|
-
}
|
|
1823
|
-
|
|
1824
|
-
options = {
|
|
1825
|
-
maxBuffer: Infinity,
|
|
1826
|
-
...options
|
|
1827
|
-
};
|
|
1828
|
-
|
|
1829
|
-
const {maxBuffer} = options;
|
|
1830
|
-
const stream = bufferStream(options);
|
|
1831
|
-
|
|
1832
|
-
await new Promise((resolve, reject) => {
|
|
1833
|
-
const rejectPromise = error => {
|
|
1834
|
-
// Don't retrieve an oversized buffer.
|
|
1835
|
-
if (error && stream.getBufferedLength() <= BufferConstants.MAX_LENGTH) {
|
|
1836
|
-
error.bufferedData = stream.getBufferedValue();
|
|
1837
|
-
}
|
|
1838
|
-
|
|
1839
|
-
reject(error);
|
|
1840
|
-
};
|
|
1841
|
-
|
|
1842
|
-
(async () => {
|
|
1843
|
-
try {
|
|
1844
|
-
await streamPipelinePromisified(inputStream, stream);
|
|
1845
|
-
resolve();
|
|
1846
|
-
} catch (error) {
|
|
1847
|
-
rejectPromise(error);
|
|
1848
|
-
}
|
|
1849
|
-
})();
|
|
1850
|
-
|
|
1851
|
-
stream.on('data', () => {
|
|
1852
|
-
if (stream.getBufferedLength() > maxBuffer) {
|
|
1853
|
-
rejectPromise(new MaxBufferError());
|
|
1854
|
-
}
|
|
1855
|
-
});
|
|
1856
|
-
});
|
|
1857
|
-
|
|
1858
|
-
return stream.getBufferedValue();
|
|
1859
|
-
}
|
|
1860
|
-
|
|
1861
|
-
getStream$2.exports = getStream;
|
|
1862
|
-
getStream$2.exports.buffer = (stream, options) => getStream(stream, {...options, encoding: 'buffer'});
|
|
1863
|
-
getStream$2.exports.array = (stream, options) => getStream(stream, {...options, array: true});
|
|
1864
|
-
getStream$2.exports.MaxBufferError = MaxBufferError;
|
|
1865
|
-
|
|
1866
|
-
var getStreamExports = getStream$2.exports;
|
|
1867
|
-
var getStream$1 = /*@__PURE__*/getDefaultExportFromCjs(getStreamExports);
|
|
1868
|
-
|
|
1869
|
-
const { PassThrough } = require$$0$2;
|
|
1870
|
-
|
|
1871
|
-
var mergeStream = function (/*streams...*/) {
|
|
1872
|
-
var sources = [];
|
|
1873
|
-
var output = new PassThrough({objectMode: true});
|
|
1874
|
-
|
|
1875
|
-
output.setMaxListeners(0);
|
|
1876
|
-
|
|
1877
|
-
output.add = add;
|
|
1878
|
-
output.isEmpty = isEmpty;
|
|
1879
|
-
|
|
1880
|
-
output.on('unpipe', remove);
|
|
1881
|
-
|
|
1882
|
-
Array.prototype.slice.call(arguments).forEach(add);
|
|
1883
|
-
|
|
1884
|
-
return output
|
|
1885
|
-
|
|
1886
|
-
function add (source) {
|
|
1887
|
-
if (Array.isArray(source)) {
|
|
1888
|
-
source.forEach(add);
|
|
1889
|
-
return this
|
|
1890
|
-
}
|
|
1891
|
-
|
|
1892
|
-
sources.push(source);
|
|
1893
|
-
source.once('end', remove.bind(null, source));
|
|
1894
|
-
source.once('error', output.emit.bind(output, 'error'));
|
|
1895
|
-
source.pipe(output, {end: false});
|
|
1896
|
-
return this
|
|
1897
|
-
}
|
|
1898
|
-
|
|
1899
|
-
function isEmpty () {
|
|
1900
|
-
return sources.length == 0;
|
|
1901
|
-
}
|
|
1902
|
-
|
|
1903
|
-
function remove (source) {
|
|
1904
|
-
sources = sources.filter(function (it) { return it !== source });
|
|
1905
|
-
if (!sources.length && output.readable) { output.end(); }
|
|
1906
|
-
}
|
|
1907
|
-
};
|
|
1908
|
-
|
|
1909
|
-
var mergeStream$1 = /*@__PURE__*/getDefaultExportFromCjs(mergeStream);
|
|
1910
|
-
|
|
1911
|
-
const validateInputOptions = input => {
|
|
1912
|
-
if (input !== undefined) {
|
|
1913
|
-
throw new TypeError('The `input` and `inputFile` options cannot be both set.');
|
|
1914
|
-
}
|
|
1915
|
-
};
|
|
1916
|
-
|
|
1917
|
-
const getInput = ({input, inputFile}) => {
|
|
1918
|
-
if (typeof inputFile !== 'string') {
|
|
1919
|
-
return input;
|
|
1920
|
-
}
|
|
1921
|
-
|
|
1922
|
-
validateInputOptions(input);
|
|
1923
|
-
return createReadStream(inputFile);
|
|
1924
|
-
};
|
|
1925
|
-
|
|
1926
|
-
// `input` and `inputFile` option in async mode
|
|
1927
|
-
const handleInput = (spawned, options) => {
|
|
1928
|
-
const input = getInput(options);
|
|
1929
|
-
|
|
1930
|
-
if (input === undefined) {
|
|
1931
|
-
return;
|
|
1932
|
-
}
|
|
1933
|
-
|
|
1934
|
-
if (isStream(input)) {
|
|
1935
|
-
input.pipe(spawned.stdin);
|
|
1936
|
-
} else {
|
|
1937
|
-
spawned.stdin.end(input);
|
|
1938
|
-
}
|
|
1939
|
-
};
|
|
1940
|
-
|
|
1941
|
-
// `all` interleaves `stdout` and `stderr`
|
|
1942
|
-
const makeAllStream = (spawned, {all}) => {
|
|
1943
|
-
if (!all || (!spawned.stdout && !spawned.stderr)) {
|
|
1944
|
-
return;
|
|
1945
|
-
}
|
|
1946
|
-
|
|
1947
|
-
const mixed = mergeStream$1();
|
|
1948
|
-
|
|
1949
|
-
if (spawned.stdout) {
|
|
1950
|
-
mixed.add(spawned.stdout);
|
|
1951
|
-
}
|
|
1952
|
-
|
|
1953
|
-
if (spawned.stderr) {
|
|
1954
|
-
mixed.add(spawned.stderr);
|
|
1955
|
-
}
|
|
1956
|
-
|
|
1957
|
-
return mixed;
|
|
1958
|
-
};
|
|
1959
|
-
|
|
1960
|
-
// On failure, `result.stdout|stderr|all` should contain the currently buffered stream
|
|
1961
|
-
const getBufferedData = async (stream, streamPromise) => {
|
|
1962
|
-
// When `buffer` is `false`, `streamPromise` is `undefined` and there is no buffered data to retrieve
|
|
1963
|
-
if (!stream || streamPromise === undefined) {
|
|
1964
|
-
return;
|
|
1965
|
-
}
|
|
1966
|
-
|
|
1967
|
-
stream.destroy();
|
|
1968
|
-
|
|
1969
|
-
try {
|
|
1970
|
-
return await streamPromise;
|
|
1971
|
-
} catch (error) {
|
|
1972
|
-
return error.bufferedData;
|
|
1973
|
-
}
|
|
1974
|
-
};
|
|
1975
|
-
|
|
1976
|
-
const getStreamPromise = (stream, {encoding, buffer, maxBuffer}) => {
|
|
1977
|
-
if (!stream || !buffer) {
|
|
1978
|
-
return;
|
|
1979
|
-
}
|
|
1980
|
-
|
|
1981
|
-
if (encoding) {
|
|
1982
|
-
return getStream$1(stream, {encoding, maxBuffer});
|
|
1983
|
-
}
|
|
1984
|
-
|
|
1985
|
-
return getStream$1.buffer(stream, {maxBuffer});
|
|
1986
|
-
};
|
|
1987
|
-
|
|
1988
|
-
// Retrieve result of child process: exit code, signal, error, streams (stdout/stderr/all)
|
|
1989
|
-
const getSpawnedResult = async ({stdout, stderr, all}, {encoding, buffer, maxBuffer}, processDone) => {
|
|
1990
|
-
const stdoutPromise = getStreamPromise(stdout, {encoding, buffer, maxBuffer});
|
|
1991
|
-
const stderrPromise = getStreamPromise(stderr, {encoding, buffer, maxBuffer});
|
|
1992
|
-
const allPromise = getStreamPromise(all, {encoding, buffer, maxBuffer: maxBuffer * 2});
|
|
1993
|
-
|
|
1994
|
-
try {
|
|
1995
|
-
return await Promise.all([processDone, stdoutPromise, stderrPromise, allPromise]);
|
|
1996
|
-
} catch (error) {
|
|
1997
|
-
return Promise.all([
|
|
1998
|
-
{error, signal: error.signal, timedOut: error.timedOut},
|
|
1999
|
-
getBufferedData(stdout, stdoutPromise),
|
|
2000
|
-
getBufferedData(stderr, stderrPromise),
|
|
2001
|
-
getBufferedData(all, allPromise),
|
|
2002
|
-
]);
|
|
2003
|
-
}
|
|
2004
|
-
};
|
|
2005
|
-
|
|
2006
|
-
// eslint-disable-next-line unicorn/prefer-top-level-await
|
|
2007
|
-
const nativePromisePrototype = (async () => {})().constructor.prototype;
|
|
2008
|
-
|
|
2009
|
-
const descriptors = ['then', 'catch', 'finally'].map(property => [
|
|
2010
|
-
property,
|
|
2011
|
-
Reflect.getOwnPropertyDescriptor(nativePromisePrototype, property),
|
|
2012
|
-
]);
|
|
2013
|
-
|
|
2014
|
-
// The return value is a mixin of `childProcess` and `Promise`
|
|
2015
|
-
const mergePromise = (spawned, promise) => {
|
|
2016
|
-
for (const [property, descriptor] of descriptors) {
|
|
2017
|
-
// Starting the main `promise` is deferred to avoid consuming streams
|
|
2018
|
-
const value = typeof promise === 'function'
|
|
2019
|
-
? (...args) => Reflect.apply(descriptor.value, promise(), args)
|
|
2020
|
-
: descriptor.value.bind(promise);
|
|
2021
|
-
|
|
2022
|
-
Reflect.defineProperty(spawned, property, {...descriptor, value});
|
|
2023
|
-
}
|
|
2024
|
-
};
|
|
2025
|
-
|
|
2026
|
-
// Use promises instead of `child_process` events
|
|
2027
|
-
const getSpawnedPromise = spawned => new Promise((resolve, reject) => {
|
|
2028
|
-
spawned.on('exit', (exitCode, signal) => {
|
|
2029
|
-
resolve({exitCode, signal});
|
|
2030
|
-
});
|
|
2031
|
-
|
|
2032
|
-
spawned.on('error', error => {
|
|
2033
|
-
reject(error);
|
|
2034
|
-
});
|
|
2035
|
-
|
|
2036
|
-
if (spawned.stdin) {
|
|
2037
|
-
spawned.stdin.on('error', error => {
|
|
2038
|
-
reject(error);
|
|
2039
|
-
});
|
|
2040
|
-
}
|
|
2041
|
-
});
|
|
2042
|
-
|
|
2043
|
-
const normalizeArgs = (file, args = []) => {
|
|
2044
|
-
if (!Array.isArray(args)) {
|
|
2045
|
-
return [file];
|
|
2046
|
-
}
|
|
2047
|
-
|
|
2048
|
-
return [file, ...args];
|
|
2049
|
-
};
|
|
2050
|
-
|
|
2051
|
-
const NO_ESCAPE_REGEXP = /^[\w.-]+$/;
|
|
2052
|
-
const DOUBLE_QUOTES_REGEXP = /"/g;
|
|
2053
|
-
|
|
2054
|
-
const escapeArg = arg => {
|
|
2055
|
-
if (typeof arg !== 'string' || NO_ESCAPE_REGEXP.test(arg)) {
|
|
2056
|
-
return arg;
|
|
2057
|
-
}
|
|
2058
|
-
|
|
2059
|
-
return `"${arg.replace(DOUBLE_QUOTES_REGEXP, '\\"')}"`;
|
|
2060
|
-
};
|
|
2061
|
-
|
|
2062
|
-
const joinCommand = (file, args) => normalizeArgs(file, args).join(' ');
|
|
2063
|
-
|
|
2064
|
-
const getEscapedCommand = (file, args) => normalizeArgs(file, args).map(arg => escapeArg(arg)).join(' ');
|
|
2065
|
-
|
|
2066
|
-
const verboseDefault = debuglog('execa').enabled;
|
|
2067
|
-
|
|
2068
|
-
const padField = (field, padding) => String(field).padStart(padding, '0');
|
|
2069
|
-
|
|
2070
|
-
const getTimestamp = () => {
|
|
2071
|
-
const date = new Date();
|
|
2072
|
-
return `${padField(date.getHours(), 2)}:${padField(date.getMinutes(), 2)}:${padField(date.getSeconds(), 2)}.${padField(date.getMilliseconds(), 3)}`;
|
|
2073
|
-
};
|
|
2074
|
-
|
|
2075
|
-
const logCommand = (escapedCommand, {verbose}) => {
|
|
2076
|
-
if (!verbose) {
|
|
2077
|
-
return;
|
|
2078
|
-
}
|
|
2079
|
-
|
|
2080
|
-
process$2.stderr.write(`[${getTimestamp()}] ${escapedCommand}\n`);
|
|
2081
|
-
};
|
|
2082
|
-
|
|
2083
|
-
const DEFAULT_MAX_BUFFER = 1000 * 1000 * 100;
|
|
2084
|
-
|
|
2085
|
-
const getEnv = ({env: envOption, extendEnv, preferLocal, localDir, execPath}) => {
|
|
2086
|
-
const env = extendEnv ? {...process$2.env, ...envOption} : envOption;
|
|
2087
|
-
|
|
2088
|
-
if (preferLocal) {
|
|
2089
|
-
return npmRunPathEnv({env, cwd: localDir, execPath});
|
|
2090
|
-
}
|
|
2091
|
-
|
|
2092
|
-
return env;
|
|
2093
|
-
};
|
|
2094
|
-
|
|
2095
|
-
const handleArguments = (file, args, options = {}) => {
|
|
2096
|
-
const parsed = crossSpawn._parse(file, args, options);
|
|
2097
|
-
file = parsed.command;
|
|
2098
|
-
args = parsed.args;
|
|
2099
|
-
options = parsed.options;
|
|
2100
|
-
|
|
2101
|
-
options = {
|
|
2102
|
-
maxBuffer: DEFAULT_MAX_BUFFER,
|
|
2103
|
-
buffer: true,
|
|
2104
|
-
stripFinalNewline: true,
|
|
2105
|
-
extendEnv: true,
|
|
2106
|
-
preferLocal: false,
|
|
2107
|
-
localDir: options.cwd || process$2.cwd(),
|
|
2108
|
-
execPath: process$2.execPath,
|
|
2109
|
-
encoding: 'utf8',
|
|
2110
|
-
reject: true,
|
|
2111
|
-
cleanup: true,
|
|
2112
|
-
all: false,
|
|
2113
|
-
windowsHide: true,
|
|
2114
|
-
verbose: verboseDefault,
|
|
2115
|
-
...options,
|
|
2116
|
-
};
|
|
2117
|
-
|
|
2118
|
-
options.env = getEnv(options);
|
|
2119
|
-
|
|
2120
|
-
options.stdio = normalizeStdio(options);
|
|
2121
|
-
|
|
2122
|
-
if (process$2.platform === 'win32' && path$3.basename(file, '.exe') === 'cmd') {
|
|
2123
|
-
// #116
|
|
2124
|
-
args.unshift('/q');
|
|
2125
|
-
}
|
|
2126
|
-
|
|
2127
|
-
return {file, args, options, parsed};
|
|
2128
|
-
};
|
|
2129
|
-
|
|
2130
|
-
const handleOutput = (options, value, error) => {
|
|
2131
|
-
if (typeof value !== 'string' && !Buffer$1.isBuffer(value)) {
|
|
2132
|
-
// When `execaSync()` errors, we normalize it to '' to mimic `execa()`
|
|
2133
|
-
return error === undefined ? undefined : '';
|
|
2134
|
-
}
|
|
2135
|
-
|
|
2136
|
-
if (options.stripFinalNewline) {
|
|
2137
|
-
return stripFinalNewline(value);
|
|
2138
|
-
}
|
|
2139
|
-
|
|
2140
|
-
return value;
|
|
2141
|
-
};
|
|
2142
|
-
|
|
2143
|
-
function execa(file, args, options) {
|
|
2144
|
-
const parsed = handleArguments(file, args, options);
|
|
2145
|
-
const command = joinCommand(file, args);
|
|
2146
|
-
const escapedCommand = getEscapedCommand(file, args);
|
|
2147
|
-
logCommand(escapedCommand, parsed.options);
|
|
2148
|
-
|
|
2149
|
-
validateTimeout(parsed.options);
|
|
2150
|
-
|
|
2151
|
-
let spawned;
|
|
2152
|
-
try {
|
|
2153
|
-
spawned = childProcess.spawn(parsed.file, parsed.args, parsed.options);
|
|
2154
|
-
} catch (error) {
|
|
2155
|
-
// Ensure the returned error is always both a promise and a child process
|
|
2156
|
-
const dummySpawned = new childProcess.ChildProcess();
|
|
2157
|
-
const errorPromise = Promise.reject(makeError({
|
|
2158
|
-
error,
|
|
2159
|
-
stdout: '',
|
|
2160
|
-
stderr: '',
|
|
2161
|
-
all: '',
|
|
2162
|
-
command,
|
|
2163
|
-
escapedCommand,
|
|
2164
|
-
parsed,
|
|
2165
|
-
timedOut: false,
|
|
2166
|
-
isCanceled: false,
|
|
2167
|
-
killed: false,
|
|
2168
|
-
}));
|
|
2169
|
-
mergePromise(dummySpawned, errorPromise);
|
|
2170
|
-
return dummySpawned;
|
|
2171
|
-
}
|
|
2172
|
-
|
|
2173
|
-
const spawnedPromise = getSpawnedPromise(spawned);
|
|
2174
|
-
const timedPromise = setupTimeout(spawned, parsed.options, spawnedPromise);
|
|
2175
|
-
const processDone = setExitHandler(spawned, parsed.options, timedPromise);
|
|
2176
|
-
|
|
2177
|
-
const context = {isCanceled: false};
|
|
2178
|
-
|
|
2179
|
-
spawned.kill = spawnedKill.bind(null, spawned.kill.bind(spawned));
|
|
2180
|
-
spawned.cancel = spawnedCancel.bind(null, spawned, context);
|
|
2181
|
-
|
|
2182
|
-
const handlePromise = async () => {
|
|
2183
|
-
const [{error, exitCode, signal, timedOut}, stdoutResult, stderrResult, allResult] = await getSpawnedResult(spawned, parsed.options, processDone);
|
|
2184
|
-
const stdout = handleOutput(parsed.options, stdoutResult);
|
|
2185
|
-
const stderr = handleOutput(parsed.options, stderrResult);
|
|
2186
|
-
const all = handleOutput(parsed.options, allResult);
|
|
2187
|
-
|
|
2188
|
-
if (error || exitCode !== 0 || signal !== null) {
|
|
2189
|
-
const returnedError = makeError({
|
|
2190
|
-
error,
|
|
2191
|
-
exitCode,
|
|
2192
|
-
signal,
|
|
2193
|
-
stdout,
|
|
2194
|
-
stderr,
|
|
2195
|
-
all,
|
|
2196
|
-
command,
|
|
2197
|
-
escapedCommand,
|
|
2198
|
-
parsed,
|
|
2199
|
-
timedOut,
|
|
2200
|
-
isCanceled: (parsed.options.signal ? parsed.options.signal.aborted : false),
|
|
2201
|
-
killed: spawned.killed,
|
|
2202
|
-
});
|
|
2203
|
-
|
|
2204
|
-
if (!parsed.options.reject) {
|
|
2205
|
-
return returnedError;
|
|
2206
|
-
}
|
|
2207
|
-
|
|
2208
|
-
throw returnedError;
|
|
2209
|
-
}
|
|
2210
|
-
|
|
2211
|
-
return {
|
|
2212
|
-
command,
|
|
2213
|
-
escapedCommand,
|
|
2214
|
-
exitCode: 0,
|
|
2215
|
-
stdout,
|
|
2216
|
-
stderr,
|
|
2217
|
-
all,
|
|
2218
|
-
failed: false,
|
|
2219
|
-
timedOut: false,
|
|
2220
|
-
isCanceled: false,
|
|
2221
|
-
killed: false,
|
|
2222
|
-
};
|
|
2223
|
-
};
|
|
2224
|
-
|
|
2225
|
-
const handlePromiseOnce = onetime(handlePromise);
|
|
2226
|
-
|
|
2227
|
-
handleInput(spawned, parsed.options);
|
|
2228
|
-
|
|
2229
|
-
spawned.all = makeAllStream(spawned, parsed.options);
|
|
2230
|
-
|
|
2231
|
-
addPipeMethods(spawned);
|
|
2232
|
-
mergePromise(spawned, handlePromiseOnce);
|
|
2233
|
-
return spawned;
|
|
2234
|
-
}
|
|
2235
|
-
|
|
2236
|
-
export { signalExit as a, crossSpawnExports as c, execa as e, getStreamExports as g, mergeStream as m, pathKeyExports as p, signalExitExports as s };
|