bililive-cli 1.7.2 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3356 +0,0 @@
1
- 'use strict';
2
-
3
- var os$3 = require('node:os');
4
- var path$5 = require('node:path');
5
- var fs$3 = require('node:fs');
6
- var crypto = require('node:crypto');
7
- var index = require('./index-YWKX2VuK.cjs');
8
- var require$$0$1 = require('fs');
9
- var require$$0 = require('path');
10
- var require$$0$2 = require('child_process');
11
- var require$$1 = require('os');
12
- var require$$1$1 = require('util');
13
- var require$$5 = require('assert');
14
- var require$$0$3 = require('events');
15
- var require$$0$5 = require('buffer');
16
- var require$$0$4 = require('stream');
17
- var process$2 = require('node:process');
18
- require('url');
19
- require('constants');
20
- require('node:events');
21
- require('ntsuspend');
22
- require('node:child_process');
23
- require('node:readline');
24
- require('http');
25
- require('https');
26
- require('zlib');
27
- require('net');
28
- require('dns');
29
- require('crypto');
30
- require('tls');
31
- require('punycode');
32
- require('tty');
33
- require('node:url');
34
- require('node:stream');
35
- require('node:stream/promises');
36
- require('vm');
37
- require('node:net');
38
- require('node:https');
39
- require('node:buffer');
40
- require('node:zlib');
41
-
42
- var xdgTrashdir$1 = {exports: {}};
43
-
44
- var df$5 = {exports: {}};
45
-
46
- var execa$2 = {exports: {}};
47
-
48
- var crossSpawn$1 = {exports: {}};
49
-
50
- const isWindows = process.platform === 'win32' ||
51
- process.env.OSTYPE === 'cygwin' ||
52
- process.env.OSTYPE === 'msys';
53
-
54
- const path$4 = require$$0;
55
- const COLON = isWindows ? ';' : ':';
56
- const isexe = index.isexe_1;
57
-
58
- const getNotFoundError = (cmd) =>
59
- Object.assign(new Error(`not found: ${cmd}`), { code: 'ENOENT' });
60
-
61
- const getPathInfo = (cmd, opt) => {
62
- const colon = opt.colon || COLON;
63
-
64
- // If it has a slash, then we don't bother searching the pathenv.
65
- // just check the file itself, and that's it.
66
- const pathEnv = cmd.match(/\//) || isWindows && cmd.match(/\\/) ? ['']
67
- : (
68
- [
69
- // windows always checks the cwd first
70
- ...(isWindows ? [process.cwd()] : []),
71
- ...(opt.path || process.env.PATH ||
72
- /* istanbul ignore next: very unusual */ '').split(colon),
73
- ]
74
- );
75
- const pathExtExe = isWindows
76
- ? opt.pathExt || process.env.PATHEXT || '.EXE;.CMD;.BAT;.COM'
77
- : '';
78
- const pathExt = isWindows ? pathExtExe.split(colon) : [''];
79
-
80
- if (isWindows) {
81
- if (cmd.indexOf('.') !== -1 && pathExt[0] !== '')
82
- pathExt.unshift('');
83
- }
84
-
85
- return {
86
- pathEnv,
87
- pathExt,
88
- pathExtExe,
89
- }
90
- };
91
-
92
- const which$1 = (cmd, opt, cb) => {
93
- if (typeof opt === 'function') {
94
- cb = opt;
95
- opt = {};
96
- }
97
- if (!opt)
98
- opt = {};
99
-
100
- const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
101
- const found = [];
102
-
103
- const step = i => new Promise((resolve, reject) => {
104
- if (i === pathEnv.length)
105
- return opt.all && found.length ? resolve(found)
106
- : reject(getNotFoundError(cmd))
107
-
108
- const ppRaw = pathEnv[i];
109
- const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
110
-
111
- const pCmd = path$4.join(pathPart, cmd);
112
- const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd
113
- : pCmd;
114
-
115
- resolve(subStep(p, i, 0));
116
- });
117
-
118
- const subStep = (p, i, ii) => new Promise((resolve, reject) => {
119
- if (ii === pathExt.length)
120
- return resolve(step(i + 1))
121
- const ext = pathExt[ii];
122
- isexe(p + ext, { pathExt: pathExtExe }, (er, is) => {
123
- if (!er && is) {
124
- if (opt.all)
125
- found.push(p + ext);
126
- else
127
- return resolve(p + ext)
128
- }
129
- return resolve(subStep(p, i, ii + 1))
130
- });
131
- });
132
-
133
- return cb ? step(0).then(res => cb(null, res), cb) : step(0)
134
- };
135
-
136
- const whichSync = (cmd, opt) => {
137
- opt = opt || {};
138
-
139
- const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
140
- const found = [];
141
-
142
- for (let i = 0; i < pathEnv.length; i ++) {
143
- const ppRaw = pathEnv[i];
144
- const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
145
-
146
- const pCmd = path$4.join(pathPart, cmd);
147
- const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd
148
- : pCmd;
149
-
150
- for (let j = 0; j < pathExt.length; j ++) {
151
- const cur = p + pathExt[j];
152
- try {
153
- const is = isexe.sync(cur, { pathExt: pathExtExe });
154
- if (is) {
155
- if (opt.all)
156
- found.push(cur);
157
- else
158
- return cur
159
- }
160
- } catch (ex) {}
161
- }
162
- }
163
-
164
- if (opt.all && found.length)
165
- return found
166
-
167
- if (opt.nothrow)
168
- return null
169
-
170
- throw getNotFoundError(cmd)
171
- };
172
-
173
- var which_1 = which$1;
174
- which$1.sync = whichSync;
175
-
176
- var pathKey$1 = {exports: {}};
177
-
178
- const pathKey = (options = {}) => {
179
- const environment = options.env || process.env;
180
- const platform = options.platform || process.platform;
181
-
182
- if (platform !== 'win32') {
183
- return 'PATH';
184
- }
185
-
186
- return Object.keys(environment).reverse().find(key => key.toUpperCase() === 'PATH') || 'Path';
187
- };
188
-
189
- pathKey$1.exports = pathKey;
190
- // TODO: Remove this for the next major release
191
- pathKey$1.exports.default = pathKey;
192
-
193
- var pathKeyExports = pathKey$1.exports;
194
-
195
- const path$3 = require$$0;
196
- const which = which_1;
197
- const getPathKey = pathKeyExports;
198
-
199
- function resolveCommandAttempt(parsed, withoutPathExt) {
200
- const env = parsed.options.env || process.env;
201
- const cwd = process.cwd();
202
- const hasCustomCwd = parsed.options.cwd != null;
203
- // Worker threads do not have process.chdir()
204
- const shouldSwitchCwd = hasCustomCwd && process.chdir !== undefined && !process.chdir.disabled;
205
-
206
- // If a custom `cwd` was specified, we need to change the process cwd
207
- // because `which` will do stat calls but does not support a custom cwd
208
- if (shouldSwitchCwd) {
209
- try {
210
- process.chdir(parsed.options.cwd);
211
- } catch (err) {
212
- /* Empty */
213
- }
214
- }
215
-
216
- let resolved;
217
-
218
- try {
219
- resolved = which.sync(parsed.command, {
220
- path: env[getPathKey({ env })],
221
- pathExt: withoutPathExt ? path$3.delimiter : undefined,
222
- });
223
- } catch (e) {
224
- /* Empty */
225
- } finally {
226
- if (shouldSwitchCwd) {
227
- process.chdir(cwd);
228
- }
229
- }
230
-
231
- // If we successfully resolved, ensure that an absolute path is returned
232
- // Note that when a custom `cwd` was used, we need to resolve to an absolute path based on it
233
- if (resolved) {
234
- resolved = path$3.resolve(hasCustomCwd ? parsed.options.cwd : '', resolved);
235
- }
236
-
237
- return resolved;
238
- }
239
-
240
- function resolveCommand$1(parsed) {
241
- return resolveCommandAttempt(parsed) || resolveCommandAttempt(parsed, true);
242
- }
243
-
244
- var resolveCommand_1 = resolveCommand$1;
245
-
246
- var _escape = {};
247
-
248
- // See http://www.robvanderwoude.com/escapechars.php
249
- const metaCharsRegExp = /([()\][%!^"`<>&|;, *?])/g;
250
-
251
- function escapeCommand(arg) {
252
- // Escape meta chars
253
- arg = arg.replace(metaCharsRegExp, '^$1');
254
-
255
- return arg;
256
- }
257
-
258
- function escapeArgument(arg, doubleEscapeMetaChars) {
259
- // Convert to string
260
- arg = `${arg}`;
261
-
262
- // Algorithm below is based on https://qntm.org/cmd
263
- // It's slightly altered to disable JS backtracking to avoid hanging on specially crafted input
264
- // Please see https://github.com/moxystudio/node-cross-spawn/pull/160 for more information
265
-
266
- // Sequence of backslashes followed by a double quote:
267
- // double up all the backslashes and escape the double quote
268
- arg = arg.replace(/(?=(\\+?)?)\1"/g, '$1$1\\"');
269
-
270
- // Sequence of backslashes followed by the end of the string
271
- // (which will become a double quote later):
272
- // double up all the backslashes
273
- arg = arg.replace(/(?=(\\+?)?)\1$/, '$1$1');
274
-
275
- // All other backslashes occur literally
276
-
277
- // Quote the whole thing:
278
- arg = `"${arg}"`;
279
-
280
- // Escape meta chars
281
- arg = arg.replace(metaCharsRegExp, '^$1');
282
-
283
- // Double escape meta chars if necessary
284
- if (doubleEscapeMetaChars) {
285
- arg = arg.replace(metaCharsRegExp, '^$1');
286
- }
287
-
288
- return arg;
289
- }
290
-
291
- _escape.command = escapeCommand;
292
- _escape.argument = escapeArgument;
293
-
294
- var shebangRegex$1 = /^#!(.*)/;
295
-
296
- const shebangRegex = shebangRegex$1;
297
-
298
- var shebangCommand$1 = (string = '') => {
299
- const match = string.match(shebangRegex);
300
-
301
- if (!match) {
302
- return null;
303
- }
304
-
305
- const [path, argument] = match[0].replace(/#! ?/, '').split(' ');
306
- const binary = path.split('/').pop();
307
-
308
- if (binary === 'env') {
309
- return argument;
310
- }
311
-
312
- return argument ? `${binary} ${argument}` : binary;
313
- };
314
-
315
- const fs$2 = require$$0$1;
316
- const shebangCommand = shebangCommand$1;
317
-
318
- function readShebang$1(command) {
319
- // Read the first 150 bytes from the file
320
- const size = 150;
321
- const buffer = Buffer.alloc(size);
322
-
323
- let fd;
324
-
325
- try {
326
- fd = fs$2.openSync(command, 'r');
327
- fs$2.readSync(fd, buffer, 0, size, 0);
328
- fs$2.closeSync(fd);
329
- } catch (e) { /* Empty */ }
330
-
331
- // Attempt to extract shebang (null is returned if not a shebang)
332
- return shebangCommand(buffer.toString());
333
- }
334
-
335
- var readShebang_1 = readShebang$1;
336
-
337
- const path$2 = require$$0;
338
- const resolveCommand = resolveCommand_1;
339
- const escape = _escape;
340
- const readShebang = readShebang_1;
341
-
342
- const isWin$2 = process.platform === 'win32';
343
- const isExecutableRegExp = /\.(?:com|exe)$/i;
344
- const isCmdShimRegExp = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
345
-
346
- function detectShebang(parsed) {
347
- parsed.file = resolveCommand(parsed);
348
-
349
- const shebang = parsed.file && readShebang(parsed.file);
350
-
351
- if (shebang) {
352
- parsed.args.unshift(parsed.file);
353
- parsed.command = shebang;
354
-
355
- return resolveCommand(parsed);
356
- }
357
-
358
- return parsed.file;
359
- }
360
-
361
- function parseNonShell(parsed) {
362
- if (!isWin$2) {
363
- return parsed;
364
- }
365
-
366
- // Detect & add support for shebangs
367
- const commandFile = detectShebang(parsed);
368
-
369
- // We don't need a shell if the command filename is an executable
370
- const needsShell = !isExecutableRegExp.test(commandFile);
371
-
372
- // If a shell is required, use cmd.exe and take care of escaping everything correctly
373
- // Note that `forceShell` is an hidden option used only in tests
374
- if (parsed.options.forceShell || needsShell) {
375
- // Need to double escape meta chars if the command is a cmd-shim located in `node_modules/.bin/`
376
- // The cmd-shim simply calls execute the package bin file with NodeJS, proxying any argument
377
- // Because the escape of metachars with ^ gets interpreted when the cmd.exe is first called,
378
- // we need to double escape them
379
- const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
380
-
381
- // Normalize posix paths into OS compatible paths (e.g.: foo/bar -> foo\bar)
382
- // This is necessary otherwise it will always fail with ENOENT in those cases
383
- parsed.command = path$2.normalize(parsed.command);
384
-
385
- // Escape command & arguments
386
- parsed.command = escape.command(parsed.command);
387
- parsed.args = parsed.args.map((arg) => escape.argument(arg, needsDoubleEscapeMetaChars));
388
-
389
- const shellCommand = [parsed.command].concat(parsed.args).join(' ');
390
-
391
- parsed.args = ['/d', '/s', '/c', `"${shellCommand}"`];
392
- parsed.command = process.env.comspec || 'cmd.exe';
393
- parsed.options.windowsVerbatimArguments = true; // Tell node's spawn that the arguments are already escaped
394
- }
395
-
396
- return parsed;
397
- }
398
-
399
- function parse$1(command, args, options) {
400
- // Normalize arguments, similar to nodejs
401
- if (args && !Array.isArray(args)) {
402
- options = args;
403
- args = null;
404
- }
405
-
406
- args = args ? args.slice(0) : []; // Clone array to avoid changing the original
407
- options = Object.assign({}, options); // Clone object to avoid changing the original
408
-
409
- // Build our parsed object
410
- const parsed = {
411
- command,
412
- args,
413
- options,
414
- file: undefined,
415
- original: {
416
- command,
417
- args,
418
- },
419
- };
420
-
421
- // Delegate further parsing to shell or non-shell
422
- return options.shell ? parsed : parseNonShell(parsed);
423
- }
424
-
425
- var parse_1 = parse$1;
426
-
427
- const isWin$1 = process.platform === 'win32';
428
-
429
- function notFoundError(original, syscall) {
430
- return Object.assign(new Error(`${syscall} ${original.command} ENOENT`), {
431
- code: 'ENOENT',
432
- errno: 'ENOENT',
433
- syscall: `${syscall} ${original.command}`,
434
- path: original.command,
435
- spawnargs: original.args,
436
- });
437
- }
438
-
439
- function hookChildProcess(cp, parsed) {
440
- if (!isWin$1) {
441
- return;
442
- }
443
-
444
- const originalEmit = cp.emit;
445
-
446
- cp.emit = function (name, arg1) {
447
- // If emitting "exit" event and exit code is 1, we need to check if
448
- // the command exists and emit an "error" instead
449
- // See https://github.com/IndigoUnited/node-cross-spawn/issues/16
450
- if (name === 'exit') {
451
- const err = verifyENOENT(arg1, parsed);
452
-
453
- if (err) {
454
- return originalEmit.call(cp, 'error', err);
455
- }
456
- }
457
-
458
- return originalEmit.apply(cp, arguments); // eslint-disable-line prefer-rest-params
459
- };
460
- }
461
-
462
- function verifyENOENT(status, parsed) {
463
- if (isWin$1 && status === 1 && !parsed.file) {
464
- return notFoundError(parsed.original, 'spawn');
465
- }
466
-
467
- return null;
468
- }
469
-
470
- function verifyENOENTSync(status, parsed) {
471
- if (isWin$1 && status === 1 && !parsed.file) {
472
- return notFoundError(parsed.original, 'spawnSync');
473
- }
474
-
475
- return null;
476
- }
477
-
478
- var enoent$1 = {
479
- hookChildProcess,
480
- verifyENOENT,
481
- verifyENOENTSync,
482
- notFoundError,
483
- };
484
-
485
- const cp = require$$0$2;
486
- const parse = parse_1;
487
- const enoent = enoent$1;
488
-
489
- function spawn(command, args, options) {
490
- // Parse the arguments
491
- const parsed = parse(command, args, options);
492
-
493
- // Spawn the child process
494
- const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);
495
-
496
- // Hook into child process "exit" event to emit an error if the command
497
- // does not exists, see: https://github.com/IndigoUnited/node-cross-spawn/issues/16
498
- enoent.hookChildProcess(spawned, parsed);
499
-
500
- return spawned;
501
- }
502
-
503
- function spawnSync(command, args, options) {
504
- // Parse the arguments
505
- const parsed = parse(command, args, options);
506
-
507
- // Spawn the child process
508
- const result = cp.spawnSync(parsed.command, parsed.args, parsed.options);
509
-
510
- // Analyze if the command does not exist, see: https://github.com/IndigoUnited/node-cross-spawn/issues/16
511
- result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
512
-
513
- return result;
514
- }
515
-
516
- crossSpawn$1.exports = spawn;
517
- crossSpawn$1.exports.spawn = spawn;
518
- crossSpawn$1.exports.sync = spawnSync;
519
-
520
- crossSpawn$1.exports._parse = parse;
521
- crossSpawn$1.exports._enoent = enoent;
522
-
523
- var crossSpawnExports = crossSpawn$1.exports;
524
-
525
- var stripFinalNewline$1 = input => {
526
- const LF = typeof input === 'string' ? '\n' : '\n'.charCodeAt();
527
- const CR = typeof input === 'string' ? '\r' : '\r'.charCodeAt();
528
-
529
- if (input[input.length - 1] === LF) {
530
- input = input.slice(0, input.length - 1);
531
- }
532
-
533
- if (input[input.length - 1] === CR) {
534
- input = input.slice(0, input.length - 1);
535
- }
536
-
537
- return input;
538
- };
539
-
540
- var npmRunPath$1 = {exports: {}};
541
-
542
- npmRunPath$1.exports;
543
-
544
- (function (module) {
545
- const path = require$$0;
546
- const pathKey = pathKeyExports;
547
-
548
- const npmRunPath = options => {
549
- options = {
550
- cwd: process.cwd(),
551
- path: process.env[pathKey()],
552
- ...options
553
- };
554
-
555
- let previous;
556
- let cwdPath = path.resolve(options.cwd);
557
- const result = [];
558
-
559
- while (previous !== cwdPath) {
560
- result.push(path.join(cwdPath, 'node_modules/.bin'));
561
- previous = cwdPath;
562
- cwdPath = path.resolve(cwdPath, '..');
563
- }
564
-
565
- // Ensure the running `node` binary is used
566
- result.push(path.dirname(process.execPath));
567
-
568
- return result.concat(options.path).join(path.delimiter);
569
- };
570
-
571
- module.exports = npmRunPath;
572
- // TODO: Remove this for the next major release
573
- module.exports.default = npmRunPath;
574
-
575
- module.exports.env = options => {
576
- options = {
577
- env: process.env,
578
- ...options
579
- };
580
-
581
- const env = {...options.env};
582
- const path = pathKey({env});
583
-
584
- options.path = env[path];
585
- env[path] = module.exports(options);
586
-
587
- return env;
588
- };
589
- } (npmRunPath$1));
590
-
591
- var npmRunPathExports = npmRunPath$1.exports;
592
-
593
- var onetime$2 = {exports: {}};
594
-
595
- var mimicFn$2 = {exports: {}};
596
-
597
- const mimicFn$1 = (to, from) => {
598
- for (const prop of Reflect.ownKeys(from)) {
599
- Object.defineProperty(to, prop, Object.getOwnPropertyDescriptor(from, prop));
600
- }
601
-
602
- return to;
603
- };
604
-
605
- mimicFn$2.exports = mimicFn$1;
606
- // TODO: Remove this for the next major release
607
- mimicFn$2.exports.default = mimicFn$1;
608
-
609
- var mimicFnExports = mimicFn$2.exports;
610
-
611
- const mimicFn = mimicFnExports;
612
-
613
- const calledFunctions = new WeakMap();
614
-
615
- const onetime$1 = (function_, options = {}) => {
616
- if (typeof function_ !== 'function') {
617
- throw new TypeError('Expected a function');
618
- }
619
-
620
- let returnValue;
621
- let callCount = 0;
622
- const functionName = function_.displayName || function_.name || '<anonymous>';
623
-
624
- const onetime = function (...arguments_) {
625
- calledFunctions.set(onetime, ++callCount);
626
-
627
- if (callCount === 1) {
628
- returnValue = function_.apply(this, arguments_);
629
- function_ = null;
630
- } else if (options.throw === true) {
631
- throw new Error(`Function \`${functionName}\` can only be called once`);
632
- }
633
-
634
- return returnValue;
635
- };
636
-
637
- mimicFn(onetime, function_);
638
- calledFunctions.set(onetime, callCount);
639
-
640
- return onetime;
641
- };
642
-
643
- onetime$2.exports = onetime$1;
644
- // TODO: Remove this for the next major release
645
- onetime$2.exports.default = onetime$1;
646
-
647
- onetime$2.exports.callCount = function_ => {
648
- if (!calledFunctions.has(function_)) {
649
- throw new Error(`The given function \`${function_.name}\` is not wrapped by the \`onetime\` package`);
650
- }
651
-
652
- return calledFunctions.get(function_);
653
- };
654
-
655
- var onetimeExports = onetime$2.exports;
656
-
657
- const os$2 = require$$1;
658
- const util = require$$1$1;
659
-
660
- const getCode = (error, code) => {
661
- if (error && error.code) {
662
- return [error.code, os$2.constants.errno[error.code]];
663
- }
664
-
665
- if (Number.isInteger(code)) {
666
- return [util.getSystemErrorName(-code), code];
667
- }
668
-
669
- return [];
670
- };
671
-
672
- const getErrorPrefix = ({timedOut, timeout, signal, exitCodeName, exitCode, isCanceled}) => {
673
- if (timedOut) {
674
- return `timed out after ${timeout} milliseconds`;
675
- }
676
-
677
- if (isCanceled) {
678
- return 'was canceled';
679
- }
680
-
681
- if (signal) {
682
- return `was killed with ${signal}`;
683
- }
684
-
685
- if (exitCode !== undefined) {
686
- return `failed with exit code ${exitCode} (${exitCodeName})`;
687
- }
688
-
689
- return 'failed';
690
- };
691
-
692
- const makeError$1 = ({
693
- stdout,
694
- stderr,
695
- all,
696
- error,
697
- signal,
698
- code,
699
- command,
700
- timedOut,
701
- isCanceled,
702
- killed,
703
- parsed: {options: {timeout}}
704
- }) => {
705
- const [exitCodeName, exitCode] = getCode(error, code);
706
-
707
- const prefix = getErrorPrefix({timedOut, timeout, signal, exitCodeName, exitCode, isCanceled});
708
- const message = `Command ${prefix}: ${command}`;
709
-
710
- if (error instanceof Error) {
711
- error.originalMessage = error.message;
712
- error.message = `${message}\n${error.message}`;
713
- } else {
714
- error = new Error(message);
715
- }
716
-
717
- error.command = command;
718
- delete error.code;
719
- error.exitCode = exitCode;
720
- error.exitCodeName = exitCodeName;
721
- error.stdout = stdout;
722
- error.stderr = stderr;
723
-
724
- if (all !== undefined) {
725
- error.all = all;
726
- }
727
-
728
- if ('bufferedData' in error) {
729
- delete error.bufferedData;
730
- }
731
-
732
- error.failed = true;
733
- error.timedOut = Boolean(timedOut);
734
- error.isCanceled = isCanceled;
735
- error.killed = killed && !timedOut;
736
- // `signal` emitted on `spawned.on('exit')` event can be `null`. We normalize
737
- // it to `undefined`
738
- error.signal = signal || undefined;
739
-
740
- return error;
741
- };
742
-
743
- var error = makeError$1;
744
-
745
- var stdio = {exports: {}};
746
-
747
- const aliases = ['stdin', 'stdout', 'stderr'];
748
-
749
- const hasAlias = opts => aliases.some(alias => opts[alias] !== undefined);
750
-
751
- const normalizeStdio$1 = opts => {
752
- if (!opts) {
753
- return;
754
- }
755
-
756
- const {stdio} = opts;
757
-
758
- if (stdio === undefined) {
759
- return aliases.map(alias => opts[alias]);
760
- }
761
-
762
- if (hasAlias(opts)) {
763
- throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${aliases.map(alias => `\`${alias}\``).join(', ')}`);
764
- }
765
-
766
- if (typeof stdio === 'string') {
767
- return stdio;
768
- }
769
-
770
- if (!Array.isArray(stdio)) {
771
- throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof stdio}\``);
772
- }
773
-
774
- const length = Math.max(stdio.length, aliases.length);
775
- return Array.from({length}, (value, index) => stdio[index]);
776
- };
777
-
778
- stdio.exports = normalizeStdio$1;
779
-
780
- // `ipc` is pushed unless it is already present
781
- stdio.exports.node = opts => {
782
- const stdio = normalizeStdio$1(opts);
783
-
784
- if (stdio === 'ipc') {
785
- return 'ipc';
786
- }
787
-
788
- if (stdio === undefined || typeof stdio === 'string') {
789
- return [stdio, stdio, stdio, 'ipc'];
790
- }
791
-
792
- if (stdio.includes('ipc')) {
793
- return stdio;
794
- }
795
-
796
- return [...stdio, 'ipc'];
797
- };
798
-
799
- var stdioExports = stdio.exports;
800
-
801
- var signalExit = {exports: {}};
802
-
803
- var signals$1 = {exports: {}};
804
-
805
- var hasRequiredSignals;
806
-
807
- function requireSignals () {
808
- if (hasRequiredSignals) return signals$1.exports;
809
- hasRequiredSignals = 1;
810
- (function (module) {
811
- // This is not the set of all possible signals.
812
- //
813
- // It IS, however, the set of all signals that trigger
814
- // an exit on either Linux or BSD systems. Linux is a
815
- // superset of the signal names supported on BSD, and
816
- // the unknown signals just fail to register, so we can
817
- // catch that easily enough.
818
- //
819
- // Don't bother with SIGKILL. It's uncatchable, which
820
- // means that we can't fire any callbacks anyway.
821
- //
822
- // If a user does happen to register a handler on a non-
823
- // fatal signal like SIGWINCH or something, and then
824
- // exit, it'll end up firing `process.emit('exit')`, so
825
- // the handler will be fired anyway.
826
- //
827
- // SIGBUS, SIGFPE, SIGSEGV and SIGILL, when not raised
828
- // artificially, inherently leave the process in a
829
- // state from which it is not safe to try and enter JS
830
- // listeners.
831
- module.exports = [
832
- 'SIGABRT',
833
- 'SIGALRM',
834
- 'SIGHUP',
835
- 'SIGINT',
836
- 'SIGTERM'
837
- ];
838
-
839
- if (process.platform !== 'win32') {
840
- module.exports.push(
841
- 'SIGVTALRM',
842
- 'SIGXCPU',
843
- 'SIGXFSZ',
844
- 'SIGUSR2',
845
- 'SIGTRAP',
846
- 'SIGSYS',
847
- 'SIGQUIT',
848
- 'SIGIOT'
849
- // should detect profiler and enable/disable accordingly.
850
- // see #21
851
- // 'SIGPROF'
852
- );
853
- }
854
-
855
- if (process.platform === 'linux') {
856
- module.exports.push(
857
- 'SIGIO',
858
- 'SIGPOLL',
859
- 'SIGPWR',
860
- 'SIGSTKFLT',
861
- 'SIGUNUSED'
862
- );
863
- }
864
- } (signals$1));
865
- return signals$1.exports;
866
- }
867
-
868
- // Note: since nyc uses this module to output coverage, any lines
869
- // that are in the direct sync flow of nyc's outputCoverage are
870
- // ignored, since we can never get coverage for them.
871
- // grab a reference to node's real process object right away
872
- var process$1 = index.commonjsGlobal.process;
873
-
874
- const processOk = function (process) {
875
- return process &&
876
- typeof process === 'object' &&
877
- typeof process.removeListener === 'function' &&
878
- typeof process.emit === 'function' &&
879
- typeof process.reallyExit === 'function' &&
880
- typeof process.listeners === 'function' &&
881
- typeof process.kill === 'function' &&
882
- typeof process.pid === 'number' &&
883
- typeof process.on === 'function'
884
- };
885
-
886
- // some kind of non-node environment, just no-op
887
- /* istanbul ignore if */
888
- if (!processOk(process$1)) {
889
- signalExit.exports = function () {
890
- return function () {}
891
- };
892
- } else {
893
- var assert = require$$5;
894
- var signals = requireSignals();
895
- var isWin = /^win/i.test(process$1.platform);
896
-
897
- var EE = require$$0$3;
898
- /* istanbul ignore if */
899
- if (typeof EE !== 'function') {
900
- EE = EE.EventEmitter;
901
- }
902
-
903
- var emitter;
904
- if (process$1.__signal_exit_emitter__) {
905
- emitter = process$1.__signal_exit_emitter__;
906
- } else {
907
- emitter = process$1.__signal_exit_emitter__ = new EE();
908
- emitter.count = 0;
909
- emitter.emitted = {};
910
- }
911
-
912
- // Because this emitter is a global, we have to check to see if a
913
- // previous version of this library failed to enable infinite listeners.
914
- // I know what you're about to say. But literally everything about
915
- // signal-exit is a compromise with evil. Get used to it.
916
- if (!emitter.infinite) {
917
- emitter.setMaxListeners(Infinity);
918
- emitter.infinite = true;
919
- }
920
-
921
- signalExit.exports = function (cb, opts) {
922
- /* istanbul ignore if */
923
- if (!processOk(index.commonjsGlobal.process)) {
924
- return function () {}
925
- }
926
- assert.equal(typeof cb, 'function', 'a callback must be provided for exit handler');
927
-
928
- if (loaded === false) {
929
- load();
930
- }
931
-
932
- var ev = 'exit';
933
- if (opts && opts.alwaysLast) {
934
- ev = 'afterexit';
935
- }
936
-
937
- var remove = function () {
938
- emitter.removeListener(ev, cb);
939
- if (emitter.listeners('exit').length === 0 &&
940
- emitter.listeners('afterexit').length === 0) {
941
- unload();
942
- }
943
- };
944
- emitter.on(ev, cb);
945
-
946
- return remove
947
- };
948
-
949
- var unload = function unload () {
950
- if (!loaded || !processOk(index.commonjsGlobal.process)) {
951
- return
952
- }
953
- loaded = false;
954
-
955
- signals.forEach(function (sig) {
956
- try {
957
- process$1.removeListener(sig, sigListeners[sig]);
958
- } catch (er) {}
959
- });
960
- process$1.emit = originalProcessEmit;
961
- process$1.reallyExit = originalProcessReallyExit;
962
- emitter.count -= 1;
963
- };
964
- signalExit.exports.unload = unload;
965
-
966
- var emit = function emit (event, code, signal) {
967
- /* istanbul ignore if */
968
- if (emitter.emitted[event]) {
969
- return
970
- }
971
- emitter.emitted[event] = true;
972
- emitter.emit(event, code, signal);
973
- };
974
-
975
- // { <signal>: <listener fn>, ... }
976
- var sigListeners = {};
977
- signals.forEach(function (sig) {
978
- sigListeners[sig] = function listener () {
979
- /* istanbul ignore if */
980
- if (!processOk(index.commonjsGlobal.process)) {
981
- return
982
- }
983
- // If there are no other listeners, an exit is coming!
984
- // Simplest way: remove us and then re-send the signal.
985
- // We know that this will kill the process, so we can
986
- // safely emit now.
987
- var listeners = process$1.listeners(sig);
988
- if (listeners.length === emitter.count) {
989
- unload();
990
- emit('exit', null, sig);
991
- /* istanbul ignore next */
992
- emit('afterexit', null, sig);
993
- /* istanbul ignore next */
994
- if (isWin && sig === 'SIGHUP') {
995
- // "SIGHUP" throws an `ENOSYS` error on Windows,
996
- // so use a supported signal instead
997
- sig = 'SIGINT';
998
- }
999
- /* istanbul ignore next */
1000
- process$1.kill(process$1.pid, sig);
1001
- }
1002
- };
1003
- });
1004
-
1005
- signalExit.exports.signals = function () {
1006
- return signals
1007
- };
1008
-
1009
- var loaded = false;
1010
-
1011
- var load = function load () {
1012
- if (loaded || !processOk(index.commonjsGlobal.process)) {
1013
- return
1014
- }
1015
- loaded = true;
1016
-
1017
- // This is the number of onSignalExit's that are in play.
1018
- // It's important so that we can count the correct number of
1019
- // listeners on signals, and don't wait for the other one to
1020
- // handle it instead of us.
1021
- emitter.count += 1;
1022
-
1023
- signals = signals.filter(function (sig) {
1024
- try {
1025
- process$1.on(sig, sigListeners[sig]);
1026
- return true
1027
- } catch (er) {
1028
- return false
1029
- }
1030
- });
1031
-
1032
- process$1.emit = processEmit;
1033
- process$1.reallyExit = processReallyExit;
1034
- };
1035
- signalExit.exports.load = load;
1036
-
1037
- var originalProcessReallyExit = process$1.reallyExit;
1038
- var processReallyExit = function processReallyExit (code) {
1039
- /* istanbul ignore if */
1040
- if (!processOk(index.commonjsGlobal.process)) {
1041
- return
1042
- }
1043
- process$1.exitCode = code || /* istanbul ignore next */ 0;
1044
- emit('exit', process$1.exitCode, null);
1045
- /* istanbul ignore next */
1046
- emit('afterexit', process$1.exitCode, null);
1047
- /* istanbul ignore next */
1048
- originalProcessReallyExit.call(process$1, process$1.exitCode);
1049
- };
1050
-
1051
- var originalProcessEmit = process$1.emit;
1052
- var processEmit = function processEmit (ev, arg) {
1053
- if (ev === 'exit' && processOk(index.commonjsGlobal.process)) {
1054
- /* istanbul ignore else */
1055
- if (arg !== undefined) {
1056
- process$1.exitCode = arg;
1057
- }
1058
- var ret = originalProcessEmit.apply(this, arguments);
1059
- /* istanbul ignore next */
1060
- emit('exit', process$1.exitCode, null);
1061
- /* istanbul ignore next */
1062
- emit('afterexit', process$1.exitCode, null);
1063
- /* istanbul ignore next */
1064
- return ret
1065
- } else {
1066
- return originalProcessEmit.apply(this, arguments)
1067
- }
1068
- };
1069
- }
1070
-
1071
- var signalExitExports = signalExit.exports;
1072
-
1073
- var pFinally$1 = async (
1074
- promise,
1075
- onFinally = (() => {})
1076
- ) => {
1077
- let value;
1078
- try {
1079
- value = await promise;
1080
- } catch (error) {
1081
- await onFinally();
1082
- throw error;
1083
- }
1084
-
1085
- await onFinally();
1086
- return value;
1087
- };
1088
-
1089
- const os$1 = require$$1;
1090
- const onExit = signalExitExports;
1091
- const pFinally = pFinally$1;
1092
-
1093
- const DEFAULT_FORCE_KILL_TIMEOUT = 1000 * 5;
1094
-
1095
- // Monkey-patches `childProcess.kill()` to add `forceKillAfterTimeout` behavior
1096
- const spawnedKill$1 = (kill, signal = 'SIGTERM', options = {}) => {
1097
- const killResult = kill(signal);
1098
- setKillTimeout(kill, signal, options, killResult);
1099
- return killResult;
1100
- };
1101
-
1102
- const setKillTimeout = (kill, signal, options, killResult) => {
1103
- if (!shouldForceKill(signal, options, killResult)) {
1104
- return;
1105
- }
1106
-
1107
- const timeout = getForceKillAfterTimeout(options);
1108
- setTimeout(() => {
1109
- kill('SIGKILL');
1110
- }, timeout).unref();
1111
- };
1112
-
1113
- const shouldForceKill = (signal, {forceKillAfterTimeout}, killResult) => {
1114
- return isSigterm(signal) && forceKillAfterTimeout !== false && killResult;
1115
- };
1116
-
1117
- const isSigterm = signal => {
1118
- return signal === os$1.constants.signals.SIGTERM ||
1119
- (typeof signal === 'string' && signal.toUpperCase() === 'SIGTERM');
1120
- };
1121
-
1122
- const getForceKillAfterTimeout = ({forceKillAfterTimeout = true}) => {
1123
- if (forceKillAfterTimeout === true) {
1124
- return DEFAULT_FORCE_KILL_TIMEOUT;
1125
- }
1126
-
1127
- if (!Number.isInteger(forceKillAfterTimeout) || forceKillAfterTimeout < 0) {
1128
- throw new TypeError(`Expected the \`forceKillAfterTimeout\` option to be a non-negative integer, got \`${forceKillAfterTimeout}\` (${typeof forceKillAfterTimeout})`);
1129
- }
1130
-
1131
- return forceKillAfterTimeout;
1132
- };
1133
-
1134
- // `childProcess.cancel()`
1135
- const spawnedCancel$1 = (spawned, context) => {
1136
- const killResult = spawned.kill();
1137
-
1138
- if (killResult) {
1139
- context.isCanceled = true;
1140
- }
1141
- };
1142
-
1143
- const timeoutKill = (spawned, signal, reject) => {
1144
- spawned.kill(signal);
1145
- reject(Object.assign(new Error('Timed out'), {timedOut: true, signal}));
1146
- };
1147
-
1148
- // `timeout` option handling
1149
- const setupTimeout$1 = (spawned, {timeout, killSignal = 'SIGTERM'}, spawnedPromise) => {
1150
- if (timeout === 0 || timeout === undefined) {
1151
- return spawnedPromise;
1152
- }
1153
-
1154
- if (!Number.isInteger(timeout) || timeout < 0) {
1155
- throw new TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${timeout}\` (${typeof timeout})`);
1156
- }
1157
-
1158
- let timeoutId;
1159
- const timeoutPromise = new Promise((resolve, reject) => {
1160
- timeoutId = setTimeout(() => {
1161
- timeoutKill(spawned, killSignal, reject);
1162
- }, timeout);
1163
- });
1164
-
1165
- const safeSpawnedPromise = pFinally(spawnedPromise, () => {
1166
- clearTimeout(timeoutId);
1167
- });
1168
-
1169
- return Promise.race([timeoutPromise, safeSpawnedPromise]);
1170
- };
1171
-
1172
- // `cleanup` option handling
1173
- const setExitHandler$1 = (spawned, {cleanup, detached}, timedPromise) => {
1174
- if (!cleanup || detached) {
1175
- return timedPromise;
1176
- }
1177
-
1178
- const removeExitHandler = onExit(() => {
1179
- spawned.kill();
1180
- });
1181
-
1182
- // TODO: Use native "finally" syntax when targeting Node.js 10
1183
- return pFinally(timedPromise, removeExitHandler);
1184
- };
1185
-
1186
- var kill = {
1187
- spawnedKill: spawnedKill$1,
1188
- spawnedCancel: spawnedCancel$1,
1189
- setupTimeout: setupTimeout$1,
1190
- setExitHandler: setExitHandler$1
1191
- };
1192
-
1193
- const isStream$1 = stream =>
1194
- stream !== null &&
1195
- typeof stream === 'object' &&
1196
- typeof stream.pipe === 'function';
1197
-
1198
- isStream$1.writable = stream =>
1199
- isStream$1(stream) &&
1200
- stream.writable !== false &&
1201
- typeof stream._write === 'function' &&
1202
- typeof stream._writableState === 'object';
1203
-
1204
- isStream$1.readable = stream =>
1205
- isStream$1(stream) &&
1206
- stream.readable !== false &&
1207
- typeof stream._read === 'function' &&
1208
- typeof stream._readableState === 'object';
1209
-
1210
- isStream$1.duplex = stream =>
1211
- isStream$1.writable(stream) &&
1212
- isStream$1.readable(stream);
1213
-
1214
- isStream$1.transform = stream =>
1215
- isStream$1.duplex(stream) &&
1216
- typeof stream._transform === 'function';
1217
-
1218
- var isStream_1 = isStream$1;
1219
-
1220
- var getStream$2 = {exports: {}};
1221
-
1222
- var once$1 = index.onceExports;
1223
-
1224
- var noop$1 = function() {};
1225
-
1226
- var isRequest$1 = function(stream) {
1227
- return stream.setHeader && typeof stream.abort === 'function';
1228
- };
1229
-
1230
- var isChildProcess = function(stream) {
1231
- return stream.stdio && Array.isArray(stream.stdio) && stream.stdio.length === 3
1232
- };
1233
-
1234
- var eos$1 = function(stream, opts, callback) {
1235
- if (typeof opts === 'function') return eos$1(stream, null, opts);
1236
- if (!opts) opts = {};
1237
-
1238
- callback = once$1(callback || noop$1);
1239
-
1240
- var ws = stream._writableState;
1241
- var rs = stream._readableState;
1242
- var readable = opts.readable || (opts.readable !== false && stream.readable);
1243
- var writable = opts.writable || (opts.writable !== false && stream.writable);
1244
- var cancelled = false;
1245
-
1246
- var onlegacyfinish = function() {
1247
- if (!stream.writable) onfinish();
1248
- };
1249
-
1250
- var onfinish = function() {
1251
- writable = false;
1252
- if (!readable) callback.call(stream);
1253
- };
1254
-
1255
- var onend = function() {
1256
- readable = false;
1257
- if (!writable) callback.call(stream);
1258
- };
1259
-
1260
- var onexit = function(exitCode) {
1261
- callback.call(stream, exitCode ? new Error('exited with error code: ' + exitCode) : null);
1262
- };
1263
-
1264
- var onerror = function(err) {
1265
- callback.call(stream, err);
1266
- };
1267
-
1268
- var onclose = function() {
1269
- process.nextTick(onclosenexttick);
1270
- };
1271
-
1272
- var onclosenexttick = function() {
1273
- if (cancelled) return;
1274
- if (readable && !(rs && (rs.ended && !rs.destroyed))) return callback.call(stream, new Error('premature close'));
1275
- if (writable && !(ws && (ws.ended && !ws.destroyed))) return callback.call(stream, new Error('premature close'));
1276
- };
1277
-
1278
- var onrequest = function() {
1279
- stream.req.on('finish', onfinish);
1280
- };
1281
-
1282
- if (isRequest$1(stream)) {
1283
- stream.on('complete', onfinish);
1284
- stream.on('abort', onclose);
1285
- if (stream.req) onrequest();
1286
- else stream.on('request', onrequest);
1287
- } else if (writable && !ws) { // legacy streams
1288
- stream.on('end', onlegacyfinish);
1289
- stream.on('close', onlegacyfinish);
1290
- }
1291
-
1292
- if (isChildProcess(stream)) stream.on('exit', onexit);
1293
-
1294
- stream.on('end', onend);
1295
- stream.on('finish', onfinish);
1296
- if (opts.error !== false) stream.on('error', onerror);
1297
- stream.on('close', onclose);
1298
-
1299
- return function() {
1300
- cancelled = true;
1301
- stream.removeListener('complete', onfinish);
1302
- stream.removeListener('abort', onclose);
1303
- stream.removeListener('request', onrequest);
1304
- if (stream.req) stream.req.removeListener('finish', onfinish);
1305
- stream.removeListener('end', onlegacyfinish);
1306
- stream.removeListener('close', onlegacyfinish);
1307
- stream.removeListener('finish', onfinish);
1308
- stream.removeListener('exit', onexit);
1309
- stream.removeListener('end', onend);
1310
- stream.removeListener('error', onerror);
1311
- stream.removeListener('close', onclose);
1312
- };
1313
- };
1314
-
1315
- var endOfStream = eos$1;
1316
-
1317
- var once = index.onceExports;
1318
- var eos = endOfStream;
1319
- var fs$1;
1320
-
1321
- try {
1322
- fs$1 = require('fs'); // we only need fs to get the ReadStream and WriteStream prototypes
1323
- } catch (e) {}
1324
-
1325
- var noop = function () {};
1326
- var ancient = /^v?\.0/.test(process.version);
1327
-
1328
- var isFn = function (fn) {
1329
- return typeof fn === 'function'
1330
- };
1331
-
1332
- var isFS = function (stream) {
1333
- if (!ancient) return false // newer node version do not need to care about fs is a special way
1334
- if (!fs$1) return false // browser
1335
- return (stream instanceof (fs$1.ReadStream || noop) || stream instanceof (fs$1.WriteStream || noop)) && isFn(stream.close)
1336
- };
1337
-
1338
- var isRequest = function (stream) {
1339
- return stream.setHeader && isFn(stream.abort)
1340
- };
1341
-
1342
- var destroyer = function (stream, reading, writing, callback) {
1343
- callback = once(callback);
1344
-
1345
- var closed = false;
1346
- stream.on('close', function () {
1347
- closed = true;
1348
- });
1349
-
1350
- eos(stream, {readable: reading, writable: writing}, function (err) {
1351
- if (err) return callback(err)
1352
- closed = true;
1353
- callback();
1354
- });
1355
-
1356
- var destroyed = false;
1357
- return function (err) {
1358
- if (closed) return
1359
- if (destroyed) return
1360
- destroyed = true;
1361
-
1362
- if (isFS(stream)) return stream.close(noop) // use close for fs streams to avoid fd leaks
1363
- if (isRequest(stream)) return stream.abort() // request.destroy just do .end - .abort is what we want
1364
-
1365
- if (isFn(stream.destroy)) return stream.destroy()
1366
-
1367
- callback(err || new Error('stream was destroyed'));
1368
- }
1369
- };
1370
-
1371
- var call = function (fn) {
1372
- fn();
1373
- };
1374
-
1375
- var pipe = function (from, to) {
1376
- return from.pipe(to)
1377
- };
1378
-
1379
- var pump$1 = function () {
1380
- var streams = Array.prototype.slice.call(arguments);
1381
- var callback = isFn(streams[streams.length - 1] || noop) && streams.pop() || noop;
1382
-
1383
- if (Array.isArray(streams[0])) streams = streams[0];
1384
- if (streams.length < 2) throw new Error('pump requires two streams per minimum')
1385
-
1386
- var error;
1387
- var destroys = streams.map(function (stream, i) {
1388
- var reading = i < streams.length - 1;
1389
- var writing = i > 0;
1390
- return destroyer(stream, reading, writing, function (err) {
1391
- if (!error) error = err;
1392
- if (err) destroys.forEach(call);
1393
- if (reading) return
1394
- destroys.forEach(call);
1395
- callback(error);
1396
- })
1397
- });
1398
-
1399
- return streams.reduce(pipe)
1400
- };
1401
-
1402
- var pump_1 = pump$1;
1403
-
1404
- const {PassThrough: PassThroughStream} = require$$0$4;
1405
-
1406
- var bufferStream$1 = options => {
1407
- options = {...options};
1408
-
1409
- const {array} = options;
1410
- let {encoding} = options;
1411
- const isBuffer = encoding === 'buffer';
1412
- let objectMode = false;
1413
-
1414
- if (array) {
1415
- objectMode = !(encoding || isBuffer);
1416
- } else {
1417
- encoding = encoding || 'utf8';
1418
- }
1419
-
1420
- if (isBuffer) {
1421
- encoding = null;
1422
- }
1423
-
1424
- const stream = new PassThroughStream({objectMode});
1425
-
1426
- if (encoding) {
1427
- stream.setEncoding(encoding);
1428
- }
1429
-
1430
- let length = 0;
1431
- const chunks = [];
1432
-
1433
- stream.on('data', chunk => {
1434
- chunks.push(chunk);
1435
-
1436
- if (objectMode) {
1437
- length = chunks.length;
1438
- } else {
1439
- length += chunk.length;
1440
- }
1441
- });
1442
-
1443
- stream.getBufferedValue = () => {
1444
- if (array) {
1445
- return chunks;
1446
- }
1447
-
1448
- return isBuffer ? Buffer.concat(chunks, length) : chunks.join('');
1449
- };
1450
-
1451
- stream.getBufferedLength = () => length;
1452
-
1453
- return stream;
1454
- };
1455
-
1456
- const {constants: BufferConstants} = require$$0$5;
1457
- const pump = pump_1;
1458
- const bufferStream = bufferStream$1;
1459
-
1460
- class MaxBufferError extends Error {
1461
- constructor() {
1462
- super('maxBuffer exceeded');
1463
- this.name = 'MaxBufferError';
1464
- }
1465
- }
1466
-
1467
- async function getStream$1(inputStream, options) {
1468
- if (!inputStream) {
1469
- return Promise.reject(new Error('Expected a stream'));
1470
- }
1471
-
1472
- options = {
1473
- maxBuffer: Infinity,
1474
- ...options
1475
- };
1476
-
1477
- const {maxBuffer} = options;
1478
-
1479
- let stream;
1480
- await new Promise((resolve, reject) => {
1481
- const rejectPromise = error => {
1482
- // Don't retrieve an oversized buffer.
1483
- if (error && stream.getBufferedLength() <= BufferConstants.MAX_LENGTH) {
1484
- error.bufferedData = stream.getBufferedValue();
1485
- }
1486
-
1487
- reject(error);
1488
- };
1489
-
1490
- stream = pump(inputStream, bufferStream(options), error => {
1491
- if (error) {
1492
- rejectPromise(error);
1493
- return;
1494
- }
1495
-
1496
- resolve();
1497
- });
1498
-
1499
- stream.on('data', () => {
1500
- if (stream.getBufferedLength() > maxBuffer) {
1501
- rejectPromise(new MaxBufferError());
1502
- }
1503
- });
1504
- });
1505
-
1506
- return stream.getBufferedValue();
1507
- }
1508
-
1509
- getStream$2.exports = getStream$1;
1510
- // TODO: Remove this for the next major release
1511
- getStream$2.exports.default = getStream$1;
1512
- getStream$2.exports.buffer = (stream, options) => getStream$1(stream, {...options, encoding: 'buffer'});
1513
- getStream$2.exports.array = (stream, options) => getStream$1(stream, {...options, array: true});
1514
- getStream$2.exports.MaxBufferError = MaxBufferError;
1515
-
1516
- var getStreamExports = getStream$2.exports;
1517
-
1518
- const { PassThrough } = require$$0$4;
1519
-
1520
- var mergeStream$1 = function (/*streams...*/) {
1521
- var sources = [];
1522
- var output = new PassThrough({objectMode: true});
1523
-
1524
- output.setMaxListeners(0);
1525
-
1526
- output.add = add;
1527
- output.isEmpty = isEmpty;
1528
-
1529
- output.on('unpipe', remove);
1530
-
1531
- Array.prototype.slice.call(arguments).forEach(add);
1532
-
1533
- return output
1534
-
1535
- function add (source) {
1536
- if (Array.isArray(source)) {
1537
- source.forEach(add);
1538
- return this
1539
- }
1540
-
1541
- sources.push(source);
1542
- source.once('end', remove.bind(null, source));
1543
- source.once('error', output.emit.bind(output, 'error'));
1544
- source.pipe(output, {end: false});
1545
- return this
1546
- }
1547
-
1548
- function isEmpty () {
1549
- return sources.length == 0;
1550
- }
1551
-
1552
- function remove (source) {
1553
- sources = sources.filter(function (it) { return it !== source });
1554
- if (!sources.length && output.readable) { output.end(); }
1555
- }
1556
- };
1557
-
1558
- const isStream = isStream_1;
1559
- const getStream = getStreamExports;
1560
- const mergeStream = mergeStream$1;
1561
-
1562
- // `input` option
1563
- const handleInput$1 = (spawned, input) => {
1564
- // Checking for stdin is workaround for https://github.com/nodejs/node/issues/26852
1565
- // TODO: Remove `|| spawned.stdin === undefined` once we drop support for Node.js <=12.2.0
1566
- if (input === undefined || spawned.stdin === undefined) {
1567
- return;
1568
- }
1569
-
1570
- if (isStream(input)) {
1571
- input.pipe(spawned.stdin);
1572
- } else {
1573
- spawned.stdin.end(input);
1574
- }
1575
- };
1576
-
1577
- // `all` interleaves `stdout` and `stderr`
1578
- const makeAllStream$1 = spawned => {
1579
- if (!spawned.stdout && !spawned.stderr) {
1580
- return;
1581
- }
1582
-
1583
- const mixed = mergeStream();
1584
-
1585
- if (spawned.stdout) {
1586
- mixed.add(spawned.stdout);
1587
- }
1588
-
1589
- if (spawned.stderr) {
1590
- mixed.add(spawned.stderr);
1591
- }
1592
-
1593
- return mixed;
1594
- };
1595
-
1596
- // On failure, `result.stdout|stderr|all` should contain the currently buffered stream
1597
- const getBufferedData = async (stream, streamPromise) => {
1598
- if (!stream) {
1599
- return;
1600
- }
1601
-
1602
- stream.destroy();
1603
-
1604
- try {
1605
- return await streamPromise;
1606
- } catch (error) {
1607
- return error.bufferedData;
1608
- }
1609
- };
1610
-
1611
- const getStreamPromise = (stream, {encoding, buffer, maxBuffer}) => {
1612
- if (!stream) {
1613
- return;
1614
- }
1615
-
1616
- if (!buffer) {
1617
- // TODO: Use `ret = util.promisify(stream.finished)(stream);` when targeting Node.js 10
1618
- return new Promise((resolve, reject) => {
1619
- stream
1620
- .once('end', resolve)
1621
- .once('error', reject);
1622
- });
1623
- }
1624
-
1625
- if (encoding) {
1626
- return getStream(stream, {encoding, maxBuffer});
1627
- }
1628
-
1629
- return getStream.buffer(stream, {maxBuffer});
1630
- };
1631
-
1632
- // Retrieve result of child process: exit code, signal, error, streams (stdout/stderr/all)
1633
- const getSpawnedResult$1 = async ({stdout, stderr, all}, {encoding, buffer, maxBuffer}, processDone) => {
1634
- const stdoutPromise = getStreamPromise(stdout, {encoding, buffer, maxBuffer});
1635
- const stderrPromise = getStreamPromise(stderr, {encoding, buffer, maxBuffer});
1636
- const allPromise = getStreamPromise(all, {encoding, buffer, maxBuffer: maxBuffer * 2});
1637
-
1638
- try {
1639
- return await Promise.all([processDone, stdoutPromise, stderrPromise, allPromise]);
1640
- } catch (error) {
1641
- return Promise.all([
1642
- {error, code: error.code, signal: error.signal, timedOut: error.timedOut},
1643
- getBufferedData(stdout, stdoutPromise),
1644
- getBufferedData(stderr, stderrPromise),
1645
- getBufferedData(all, allPromise)
1646
- ]);
1647
- }
1648
- };
1649
-
1650
- const validateInputSync$1 = ({input}) => {
1651
- if (isStream(input)) {
1652
- throw new TypeError('The `input` option cannot be a stream in sync mode');
1653
- }
1654
- };
1655
-
1656
- var stream = {
1657
- handleInput: handleInput$1,
1658
- makeAllStream: makeAllStream$1,
1659
- getSpawnedResult: getSpawnedResult$1,
1660
- validateInputSync: validateInputSync$1
1661
- };
1662
-
1663
- const mergePromiseProperty = (spawned, promise, property) => {
1664
- // Starting the main `promise` is deferred to avoid consuming streams
1665
- const value = typeof promise === 'function' ?
1666
- (...args) => promise()[property](...args) :
1667
- promise[property].bind(promise);
1668
-
1669
- Object.defineProperty(spawned, property, {
1670
- value,
1671
- writable: true,
1672
- enumerable: false,
1673
- configurable: true
1674
- });
1675
- };
1676
-
1677
- // The return value is a mixin of `childProcess` and `Promise`
1678
- const mergePromise$1 = (spawned, promise) => {
1679
- mergePromiseProperty(spawned, promise, 'then');
1680
- mergePromiseProperty(spawned, promise, 'catch');
1681
-
1682
- // TODO: Remove the `if`-guard when targeting Node.js 10
1683
- if (Promise.prototype.finally) {
1684
- mergePromiseProperty(spawned, promise, 'finally');
1685
- }
1686
-
1687
- return spawned;
1688
- };
1689
-
1690
- // Use promises instead of `child_process` events
1691
- const getSpawnedPromise$1 = spawned => {
1692
- return new Promise((resolve, reject) => {
1693
- spawned.on('exit', (code, signal) => {
1694
- resolve({code, signal});
1695
- });
1696
-
1697
- spawned.on('error', error => {
1698
- reject(error);
1699
- });
1700
-
1701
- if (spawned.stdin) {
1702
- spawned.stdin.on('error', error => {
1703
- reject(error);
1704
- });
1705
- }
1706
- });
1707
- };
1708
-
1709
- var promise = {
1710
- mergePromise: mergePromise$1,
1711
- getSpawnedPromise: getSpawnedPromise$1
1712
- };
1713
-
1714
- const SPACES_REGEXP = / +/g;
1715
-
1716
- const joinCommand$1 = (file, args = []) => {
1717
- if (!Array.isArray(args)) {
1718
- return file;
1719
- }
1720
-
1721
- return [file, ...args].join(' ');
1722
- };
1723
-
1724
- // Allow spaces to be escaped by a backslash if not meant as a delimiter
1725
- const handleEscaping = (tokens, token, index) => {
1726
- if (index === 0) {
1727
- return [token];
1728
- }
1729
-
1730
- const previousToken = tokens[tokens.length - 1];
1731
-
1732
- if (previousToken.endsWith('\\')) {
1733
- return [...tokens.slice(0, -1), `${previousToken.slice(0, -1)} ${token}`];
1734
- }
1735
-
1736
- return [...tokens, token];
1737
- };
1738
-
1739
- // Handle `execa.command()`
1740
- const parseCommand$1 = command => {
1741
- return command
1742
- .trim()
1743
- .split(SPACES_REGEXP)
1744
- .reduce(handleEscaping, []);
1745
- };
1746
-
1747
- var command = {
1748
- joinCommand: joinCommand$1,
1749
- parseCommand: parseCommand$1
1750
- };
1751
-
1752
- const path$1 = require$$0;
1753
- const childProcess$1 = require$$0$2;
1754
- const crossSpawn = crossSpawnExports;
1755
- const stripFinalNewline = stripFinalNewline$1;
1756
- const npmRunPath = npmRunPathExports;
1757
- const onetime = onetimeExports;
1758
- const makeError = error;
1759
- const normalizeStdio = stdioExports;
1760
- const {spawnedKill, spawnedCancel, setupTimeout, setExitHandler} = kill;
1761
- const {handleInput, getSpawnedResult, makeAllStream, validateInputSync} = stream;
1762
- const {mergePromise, getSpawnedPromise} = promise;
1763
- const {joinCommand, parseCommand} = command;
1764
-
1765
- const DEFAULT_MAX_BUFFER = 1000 * 1000 * 100;
1766
-
1767
- const getEnv = ({env: envOption, extendEnv, preferLocal, localDir}) => {
1768
- const env = extendEnv ? {...process.env, ...envOption} : envOption;
1769
-
1770
- if (preferLocal) {
1771
- return npmRunPath.env({env, cwd: localDir});
1772
- }
1773
-
1774
- return env;
1775
- };
1776
-
1777
- const handleArgs = (file, args, options = {}) => {
1778
- const parsed = crossSpawn._parse(file, args, options);
1779
- file = parsed.command;
1780
- args = parsed.args;
1781
- options = parsed.options;
1782
-
1783
- options = {
1784
- maxBuffer: DEFAULT_MAX_BUFFER,
1785
- buffer: true,
1786
- stripFinalNewline: true,
1787
- extendEnv: true,
1788
- preferLocal: false,
1789
- localDir: options.cwd || process.cwd(),
1790
- encoding: 'utf8',
1791
- reject: true,
1792
- cleanup: true,
1793
- ...options,
1794
- windowsHide: true
1795
- };
1796
-
1797
- options.env = getEnv(options);
1798
-
1799
- options.stdio = normalizeStdio(options);
1800
-
1801
- if (process.platform === 'win32' && path$1.basename(file, '.exe') === 'cmd') {
1802
- // #116
1803
- args.unshift('/q');
1804
- }
1805
-
1806
- return {file, args, options, parsed};
1807
- };
1808
-
1809
- const handleOutput = (options, value, error) => {
1810
- if (typeof value !== 'string' && !Buffer.isBuffer(value)) {
1811
- // When `execa.sync()` errors, we normalize it to '' to mimic `execa()`
1812
- return error === undefined ? undefined : '';
1813
- }
1814
-
1815
- if (options.stripFinalNewline) {
1816
- return stripFinalNewline(value);
1817
- }
1818
-
1819
- return value;
1820
- };
1821
-
1822
- const execa$1 = (file, args, options) => {
1823
- const parsed = handleArgs(file, args, options);
1824
- const command = joinCommand(file, args);
1825
-
1826
- let spawned;
1827
- try {
1828
- spawned = childProcess$1.spawn(parsed.file, parsed.args, parsed.options);
1829
- } catch (error) {
1830
- // Ensure the returned error is always both a promise and a child process
1831
- const dummySpawned = new childProcess$1.ChildProcess();
1832
- const errorPromise = Promise.reject(makeError({
1833
- error,
1834
- stdout: '',
1835
- stderr: '',
1836
- all: '',
1837
- command,
1838
- parsed,
1839
- timedOut: false,
1840
- isCanceled: false,
1841
- killed: false
1842
- }));
1843
- return mergePromise(dummySpawned, errorPromise);
1844
- }
1845
-
1846
- const spawnedPromise = getSpawnedPromise(spawned);
1847
- const timedPromise = setupTimeout(spawned, parsed.options, spawnedPromise);
1848
- const processDone = setExitHandler(spawned, parsed.options, timedPromise);
1849
-
1850
- const context = {isCanceled: false};
1851
-
1852
- spawned.kill = spawnedKill.bind(null, spawned.kill.bind(spawned));
1853
- spawned.cancel = spawnedCancel.bind(null, spawned, context);
1854
-
1855
- const handlePromise = async () => {
1856
- const [{error, code, signal, timedOut}, stdoutResult, stderrResult, allResult] = await getSpawnedResult(spawned, parsed.options, processDone);
1857
- const stdout = handleOutput(parsed.options, stdoutResult);
1858
- const stderr = handleOutput(parsed.options, stderrResult);
1859
- const all = handleOutput(parsed.options, allResult);
1860
-
1861
- if (error || code !== 0 || signal !== null) {
1862
- const returnedError = makeError({
1863
- error,
1864
- code,
1865
- signal,
1866
- stdout,
1867
- stderr,
1868
- all,
1869
- command,
1870
- parsed,
1871
- timedOut,
1872
- isCanceled: context.isCanceled,
1873
- killed: spawned.killed
1874
- });
1875
-
1876
- if (!parsed.options.reject) {
1877
- return returnedError;
1878
- }
1879
-
1880
- throw returnedError;
1881
- }
1882
-
1883
- return {
1884
- command,
1885
- exitCode: 0,
1886
- exitCodeName: 'SUCCESS',
1887
- stdout,
1888
- stderr,
1889
- all,
1890
- failed: false,
1891
- timedOut: false,
1892
- isCanceled: false,
1893
- killed: false
1894
- };
1895
- };
1896
-
1897
- const handlePromiseOnce = onetime(handlePromise);
1898
-
1899
- crossSpawn._enoent.hookChildProcess(spawned, parsed.parsed);
1900
-
1901
- handleInput(spawned, parsed.options.input);
1902
-
1903
- spawned.all = makeAllStream(spawned);
1904
-
1905
- return mergePromise(spawned, handlePromiseOnce);
1906
- };
1907
-
1908
- execa$2.exports = execa$1;
1909
-
1910
- execa$2.exports.sync = (file, args, options) => {
1911
- const parsed = handleArgs(file, args, options);
1912
- const command = joinCommand(file, args);
1913
-
1914
- validateInputSync(parsed.options);
1915
-
1916
- let result;
1917
- try {
1918
- result = childProcess$1.spawnSync(parsed.file, parsed.args, parsed.options);
1919
- } catch (error) {
1920
- throw makeError({
1921
- error,
1922
- stdout: '',
1923
- stderr: '',
1924
- all: '',
1925
- command,
1926
- parsed,
1927
- timedOut: false,
1928
- isCanceled: false,
1929
- killed: false
1930
- });
1931
- }
1932
-
1933
- result.stdout = handleOutput(parsed.options, result.stdout, result.error);
1934
- result.stderr = handleOutput(parsed.options, result.stderr, result.error);
1935
-
1936
- if (result.error || result.status !== 0 || result.signal !== null) {
1937
- const error = makeError({
1938
- ...result,
1939
- code: result.status,
1940
- command,
1941
- parsed,
1942
- timedOut: result.error && result.error.code === 'ETIMEDOUT',
1943
- isCanceled: false,
1944
- killed: result.signal !== null
1945
- });
1946
-
1947
- if (!parsed.options.reject) {
1948
- return error;
1949
- }
1950
-
1951
- throw error;
1952
- }
1953
-
1954
- return {
1955
- command,
1956
- exitCode: 0,
1957
- exitCodeName: 'SUCCESS',
1958
- stdout: result.stdout,
1959
- stderr: result.stderr,
1960
- failed: false,
1961
- timedOut: false,
1962
- isCanceled: false,
1963
- killed: false
1964
- };
1965
- };
1966
-
1967
- execa$2.exports.command = (command, options) => {
1968
- const [file, ...args] = parseCommand(command);
1969
- return execa$1(file, args, options);
1970
- };
1971
-
1972
- execa$2.exports.commandSync = (command, options) => {
1973
- const [file, ...args] = parseCommand(command);
1974
- return execa$1.sync(file, args, options);
1975
- };
1976
-
1977
- execa$2.exports.node = (scriptPath, args, options = {}) => {
1978
- if (args && !Array.isArray(args) && typeof args === 'object') {
1979
- options = args;
1980
- args = [];
1981
- }
1982
-
1983
- const stdio = normalizeStdio.node(options);
1984
-
1985
- const {nodePath = process.execPath, nodeOptions = process.execArgv} = options;
1986
-
1987
- return execa$1(
1988
- nodePath,
1989
- [
1990
- ...nodeOptions,
1991
- scriptPath,
1992
- ...(Array.isArray(args) ? args : [])
1993
- ],
1994
- {
1995
- ...options,
1996
- stdin: undefined,
1997
- stdout: undefined,
1998
- stderr: undefined,
1999
- stdio,
2000
- shell: false
2001
- }
2002
- );
2003
- };
2004
-
2005
- var execaExports = execa$2.exports;
2006
-
2007
- const execa = execaExports;
2008
-
2009
- const getColumnBoundaries = async header => {
2010
- // Regex captures each individual column
2011
- // ^\S+\s+ -> First column
2012
- // \s*\S+\s*\S+$ -> Last column (combined)
2013
- // \s*\S+ -> Regular columns
2014
- const regex = /^\S+\s+|\s*\S+\s*\S+$|\s*\S+/g;
2015
- const boundaries = [];
2016
- let match;
2017
-
2018
- while ((match = regex.exec(header))) {
2019
- boundaries.push(match[0].length);
2020
- }
2021
-
2022
- // Extend last column boundary
2023
- boundaries[boundaries.length - 1] = -1;
2024
-
2025
- return boundaries;
2026
- };
2027
-
2028
- const parseOutput = async output => {
2029
- const lines = output.trim().split('\n');
2030
- const boundaries = await getColumnBoundaries(lines[0]);
2031
-
2032
- return lines.slice(1).map(line => {
2033
- const cl = boundaries.map(boundary => {
2034
- // Handle extra-long last column
2035
- const column = boundary > 0 ? line.slice(0, boundary) : line;
2036
- line = line.slice(boundary);
2037
- return column.trim();
2038
- });
2039
-
2040
- return {
2041
- filesystem: cl[0],
2042
- size: parseInt(cl[1], 10) * 1024,
2043
- used: parseInt(cl[2], 10) * 1024,
2044
- available: parseInt(cl[3], 10) * 1024,
2045
- capacity: parseInt(cl[4], 10) / 100,
2046
- mountpoint: cl[5]
2047
- };
2048
- });
2049
- };
2050
-
2051
- const run$1 = async args => {
2052
- const {stdout} = await execa('df', args);
2053
- return parseOutput(stdout);
2054
- };
2055
-
2056
- const df$4 = async () => run$1(['-kP']);
2057
-
2058
- df$4.fs = async name => {
2059
- if (typeof name !== 'string') {
2060
- throw new TypeError('The `name` parameter required');
2061
- }
2062
-
2063
- const data = await run$1(['-kP']);
2064
-
2065
- for (const item of data) {
2066
- if (item.filesystem === name) {
2067
- return item;
2068
- }
2069
- }
2070
-
2071
- throw new Error(`The specified filesystem \`${name}\` doesn't exist`);
2072
- };
2073
-
2074
- df$4.file = async file => {
2075
- if (typeof file !== 'string') {
2076
- throw new TypeError('The `file` parameter is required');
2077
- }
2078
-
2079
- let data;
2080
- try {
2081
- data = await run$1(['-kP', file]);
2082
- } catch (error) {
2083
- if (/No such file or directory/.test(error.stderr)) {
2084
- throw new Error(`The specified file \`${file}\` doesn't exist`);
2085
- }
2086
-
2087
- throw error;
2088
- }
2089
-
2090
- return data[0];
2091
- };
2092
-
2093
- df$5.exports = df$4;
2094
- // TODO: remove this in the next major version
2095
- df$5.exports.default = df$4;
2096
-
2097
- if (process.env.NODE_ENV === 'test') {
2098
- df$5.exports._parseOutput = parseOutput;
2099
- }
2100
-
2101
- var dfExports$1 = df$5.exports;
2102
-
2103
- var df$3 = {exports: {}};
2104
-
2105
- var childProcess = require$$0$2;
2106
-
2107
- function run(args, cb) {
2108
- childProcess.execFile('df', args, function (err, stdout) {
2109
- if (err) {
2110
- cb(err);
2111
- return;
2112
- }
2113
-
2114
- cb(null, stdout.trim().split('\n').slice(1).map(function (el) {
2115
- var cl = el.split(/\s+(?=[\d\/])/);
2116
-
2117
- return {
2118
- filesystem: cl[0],
2119
- size: parseInt(cl[1], 10) * 1024,
2120
- used: parseInt(cl[2], 10) * 1024,
2121
- available: parseInt(cl[3], 10) * 1024,
2122
- capacity: parseInt(cl[4], 10) / 100,
2123
- mountpoint: cl[5]
2124
- };
2125
- }));
2126
- });
2127
- }
2128
- var df$2 = df$3.exports = function (cb) {
2129
- run(['-kP'], cb);
2130
- };
2131
-
2132
- df$2.fs = function (name, cb) {
2133
- if (typeof name !== 'string') {
2134
- throw new Error('name required');
2135
- }
2136
-
2137
- run(['-kP'], function (err, data) {
2138
- if (err) {
2139
- cb(err);
2140
- return;
2141
- }
2142
-
2143
- var ret;
2144
-
2145
- data.forEach(function (el) {
2146
- if (el.filesystem === name) {
2147
- ret = el;
2148
- }
2149
- });
2150
-
2151
- cb(null, ret);
2152
- });
2153
- };
2154
-
2155
- df$2.file = function (file, cb) {
2156
- if (typeof file !== 'string') {
2157
- throw new Error('file required');
2158
- }
2159
-
2160
- run(['-kP', file], function (err, data) {
2161
- if (err) {
2162
- cb(err);
2163
- return;
2164
- }
2165
-
2166
- cb(null, data[0]);
2167
- });
2168
- };
2169
-
2170
- var dfExports = df$3.exports;
2171
-
2172
- var pify$2 = {exports: {}};
2173
-
2174
- var processFn = function (fn, P, opts) {
2175
- return function () {
2176
- var that = this;
2177
- var args = new Array(arguments.length);
2178
-
2179
- for (var i = 0; i < arguments.length; i++) {
2180
- args[i] = arguments[i];
2181
- }
2182
-
2183
- return new P(function (resolve, reject) {
2184
- args.push(function (err, result) {
2185
- if (err) {
2186
- reject(err);
2187
- } else if (opts.multiArgs) {
2188
- var results = new Array(arguments.length - 1);
2189
-
2190
- for (var i = 1; i < arguments.length; i++) {
2191
- results[i - 1] = arguments[i];
2192
- }
2193
-
2194
- resolve(results);
2195
- } else {
2196
- resolve(result);
2197
- }
2198
- });
2199
-
2200
- fn.apply(that, args);
2201
- });
2202
- };
2203
- };
2204
-
2205
- var pify$1 = pify$2.exports = function (obj, P, opts) {
2206
- if (typeof P !== 'function') {
2207
- opts = P;
2208
- P = Promise;
2209
- }
2210
-
2211
- opts = opts || {};
2212
- opts.exclude = opts.exclude || [/.+Sync$/];
2213
-
2214
- var filter = function (key) {
2215
- var match = function (pattern) {
2216
- return typeof pattern === 'string' ? key === pattern : pattern.test(key);
2217
- };
2218
-
2219
- return opts.include ? opts.include.some(match) : !opts.exclude.some(match);
2220
- };
2221
-
2222
- var ret = typeof obj === 'function' ? function () {
2223
- if (opts.excludeMain) {
2224
- return obj.apply(this, arguments);
2225
- }
2226
-
2227
- return processFn(obj, P, opts).apply(this, arguments);
2228
- } : {};
2229
-
2230
- return Object.keys(obj).reduce(function (ret, key) {
2231
- var x = obj[key];
2232
-
2233
- ret[key] = typeof x === 'function' && filter(key) ? processFn(x, P, opts) : x;
2234
-
2235
- return ret;
2236
- }, ret);
2237
- };
2238
-
2239
- pify$1.all = pify$1;
2240
-
2241
- var pifyExports = pify$2.exports;
2242
-
2243
- var pinkie;
2244
- var hasRequiredPinkie;
2245
-
2246
- function requirePinkie () {
2247
- if (hasRequiredPinkie) return pinkie;
2248
- hasRequiredPinkie = 1;
2249
-
2250
- var PENDING = 'pending';
2251
- var SETTLED = 'settled';
2252
- var FULFILLED = 'fulfilled';
2253
- var REJECTED = 'rejected';
2254
- var NOOP = function () {};
2255
- var isNode = typeof index.commonjsGlobal !== 'undefined' && typeof index.commonjsGlobal.process !== 'undefined' && typeof index.commonjsGlobal.process.emit === 'function';
2256
-
2257
- var asyncSetTimer = typeof setImmediate === 'undefined' ? setTimeout : setImmediate;
2258
- var asyncQueue = [];
2259
- var asyncTimer;
2260
-
2261
- function asyncFlush() {
2262
- // run promise callbacks
2263
- for (var i = 0; i < asyncQueue.length; i++) {
2264
- asyncQueue[i][0](asyncQueue[i][1]);
2265
- }
2266
-
2267
- // reset async asyncQueue
2268
- asyncQueue = [];
2269
- asyncTimer = false;
2270
- }
2271
-
2272
- function asyncCall(callback, arg) {
2273
- asyncQueue.push([callback, arg]);
2274
-
2275
- if (!asyncTimer) {
2276
- asyncTimer = true;
2277
- asyncSetTimer(asyncFlush, 0);
2278
- }
2279
- }
2280
-
2281
- function invokeResolver(resolver, promise) {
2282
- function resolvePromise(value) {
2283
- resolve(promise, value);
2284
- }
2285
-
2286
- function rejectPromise(reason) {
2287
- reject(promise, reason);
2288
- }
2289
-
2290
- try {
2291
- resolver(resolvePromise, rejectPromise);
2292
- } catch (e) {
2293
- rejectPromise(e);
2294
- }
2295
- }
2296
-
2297
- function invokeCallback(subscriber) {
2298
- var owner = subscriber.owner;
2299
- var settled = owner._state;
2300
- var value = owner._data;
2301
- var callback = subscriber[settled];
2302
- var promise = subscriber.then;
2303
-
2304
- if (typeof callback === 'function') {
2305
- settled = FULFILLED;
2306
- try {
2307
- value = callback(value);
2308
- } catch (e) {
2309
- reject(promise, e);
2310
- }
2311
- }
2312
-
2313
- if (!handleThenable(promise, value)) {
2314
- if (settled === FULFILLED) {
2315
- resolve(promise, value);
2316
- }
2317
-
2318
- if (settled === REJECTED) {
2319
- reject(promise, value);
2320
- }
2321
- }
2322
- }
2323
-
2324
- function handleThenable(promise, value) {
2325
- var resolved;
2326
-
2327
- try {
2328
- if (promise === value) {
2329
- throw new TypeError('A promises callback cannot return that same promise.');
2330
- }
2331
-
2332
- if (value && (typeof value === 'function' || typeof value === 'object')) {
2333
- // then should be retrieved only once
2334
- var then = value.then;
2335
-
2336
- if (typeof then === 'function') {
2337
- then.call(value, function (val) {
2338
- if (!resolved) {
2339
- resolved = true;
2340
-
2341
- if (value === val) {
2342
- fulfill(promise, val);
2343
- } else {
2344
- resolve(promise, val);
2345
- }
2346
- }
2347
- }, function (reason) {
2348
- if (!resolved) {
2349
- resolved = true;
2350
-
2351
- reject(promise, reason);
2352
- }
2353
- });
2354
-
2355
- return true;
2356
- }
2357
- }
2358
- } catch (e) {
2359
- if (!resolved) {
2360
- reject(promise, e);
2361
- }
2362
-
2363
- return true;
2364
- }
2365
-
2366
- return false;
2367
- }
2368
-
2369
- function resolve(promise, value) {
2370
- if (promise === value || !handleThenable(promise, value)) {
2371
- fulfill(promise, value);
2372
- }
2373
- }
2374
-
2375
- function fulfill(promise, value) {
2376
- if (promise._state === PENDING) {
2377
- promise._state = SETTLED;
2378
- promise._data = value;
2379
-
2380
- asyncCall(publishFulfillment, promise);
2381
- }
2382
- }
2383
-
2384
- function reject(promise, reason) {
2385
- if (promise._state === PENDING) {
2386
- promise._state = SETTLED;
2387
- promise._data = reason;
2388
-
2389
- asyncCall(publishRejection, promise);
2390
- }
2391
- }
2392
-
2393
- function publish(promise) {
2394
- promise._then = promise._then.forEach(invokeCallback);
2395
- }
2396
-
2397
- function publishFulfillment(promise) {
2398
- promise._state = FULFILLED;
2399
- publish(promise);
2400
- }
2401
-
2402
- function publishRejection(promise) {
2403
- promise._state = REJECTED;
2404
- publish(promise);
2405
- if (!promise._handled && isNode) {
2406
- index.commonjsGlobal.process.emit('unhandledRejection', promise._data, promise);
2407
- }
2408
- }
2409
-
2410
- function notifyRejectionHandled(promise) {
2411
- index.commonjsGlobal.process.emit('rejectionHandled', promise);
2412
- }
2413
-
2414
- /**
2415
- * @class
2416
- */
2417
- function Promise(resolver) {
2418
- if (typeof resolver !== 'function') {
2419
- throw new TypeError('Promise resolver ' + resolver + ' is not a function');
2420
- }
2421
-
2422
- if (this instanceof Promise === false) {
2423
- throw new TypeError('Failed to construct \'Promise\': Please use the \'new\' operator, this object constructor cannot be called as a function.');
2424
- }
2425
-
2426
- this._then = [];
2427
-
2428
- invokeResolver(resolver, this);
2429
- }
2430
-
2431
- Promise.prototype = {
2432
- constructor: Promise,
2433
-
2434
- _state: PENDING,
2435
- _then: null,
2436
- _data: undefined,
2437
- _handled: false,
2438
-
2439
- then: function (onFulfillment, onRejection) {
2440
- var subscriber = {
2441
- owner: this,
2442
- then: new this.constructor(NOOP),
2443
- fulfilled: onFulfillment,
2444
- rejected: onRejection
2445
- };
2446
-
2447
- if ((onRejection || onFulfillment) && !this._handled) {
2448
- this._handled = true;
2449
- if (this._state === REJECTED && isNode) {
2450
- asyncCall(notifyRejectionHandled, this);
2451
- }
2452
- }
2453
-
2454
- if (this._state === FULFILLED || this._state === REJECTED) {
2455
- // already resolved, call callback async
2456
- asyncCall(invokeCallback, subscriber);
2457
- } else {
2458
- // subscribe
2459
- this._then.push(subscriber);
2460
- }
2461
-
2462
- return subscriber.then;
2463
- },
2464
-
2465
- catch: function (onRejection) {
2466
- return this.then(null, onRejection);
2467
- }
2468
- };
2469
-
2470
- Promise.all = function (promises) {
2471
- if (!Array.isArray(promises)) {
2472
- throw new TypeError('You must pass an array to Promise.all().');
2473
- }
2474
-
2475
- return new Promise(function (resolve, reject) {
2476
- var results = [];
2477
- var remaining = 0;
2478
-
2479
- function resolver(index) {
2480
- remaining++;
2481
- return function (value) {
2482
- results[index] = value;
2483
- if (!--remaining) {
2484
- resolve(results);
2485
- }
2486
- };
2487
- }
2488
-
2489
- for (var i = 0, promise; i < promises.length; i++) {
2490
- promise = promises[i];
2491
-
2492
- if (promise && typeof promise.then === 'function') {
2493
- promise.then(resolver(i), reject);
2494
- } else {
2495
- results[i] = promise;
2496
- }
2497
- }
2498
-
2499
- if (!remaining) {
2500
- resolve(results);
2501
- }
2502
- });
2503
- };
2504
-
2505
- Promise.race = function (promises) {
2506
- if (!Array.isArray(promises)) {
2507
- throw new TypeError('You must pass an array to Promise.race().');
2508
- }
2509
-
2510
- return new Promise(function (resolve, reject) {
2511
- for (var i = 0, promise; i < promises.length; i++) {
2512
- promise = promises[i];
2513
-
2514
- if (promise && typeof promise.then === 'function') {
2515
- promise.then(resolve, reject);
2516
- } else {
2517
- resolve(promise);
2518
- }
2519
- }
2520
- });
2521
- };
2522
-
2523
- Promise.resolve = function (value) {
2524
- if (value && typeof value === 'object' && value.constructor === Promise) {
2525
- return value;
2526
- }
2527
-
2528
- return new Promise(function (resolve) {
2529
- resolve(value);
2530
- });
2531
- };
2532
-
2533
- Promise.reject = function (reason) {
2534
- return new Promise(function (resolve, reject) {
2535
- reject(reason);
2536
- });
2537
- };
2538
-
2539
- pinkie = Promise;
2540
- return pinkie;
2541
- }
2542
-
2543
- var pinkiePromise = typeof Promise === 'function' ? Promise : requirePinkie();
2544
-
2545
- var df$1 = dfExports;
2546
- var pify = pifyExports;
2547
- var Promise$1 = pinkiePromise;
2548
-
2549
- var mountPoint$1 = function (file) {
2550
- return pify(df$1.file, Promise$1)(file).then(function (data) {
2551
- return data.mountpoint;
2552
- });
2553
- };
2554
-
2555
- var os = require$$1;
2556
-
2557
- function homedir() {
2558
- var env = process.env;
2559
- var home = env.HOME;
2560
- var user = env.LOGNAME || env.USER || env.LNAME || env.USERNAME;
2561
-
2562
- if (process.platform === 'win32') {
2563
- return env.USERPROFILE || env.HOMEDRIVE + env.HOMEPATH || home || null;
2564
- }
2565
-
2566
- if (process.platform === 'darwin') {
2567
- return home || (user ? '/Users/' + user : null);
2568
- }
2569
-
2570
- if (process.platform === 'linux') {
2571
- return home || (process.getuid() === 0 ? '/root' : (user ? '/home/' + user : null));
2572
- }
2573
-
2574
- return home || null;
2575
- }
2576
-
2577
- var osHomedir = typeof os.homedir === 'function' ? os.homedir : homedir;
2578
-
2579
- var userHome$1 = osHomedir();
2580
-
2581
- var xdgBasedir$1 = {};
2582
-
2583
- (function (exports) {
2584
- const os = require$$1;
2585
- const path = require$$0;
2586
-
2587
- const homeDirectory = os.homedir();
2588
- const {env} = process;
2589
-
2590
- exports.data = env.XDG_DATA_HOME ||
2591
- (homeDirectory ? path.join(homeDirectory, '.local', 'share') : undefined);
2592
-
2593
- exports.config = env.XDG_CONFIG_HOME ||
2594
- (homeDirectory ? path.join(homeDirectory, '.config') : undefined);
2595
-
2596
- exports.cache = env.XDG_CACHE_HOME || (homeDirectory ? path.join(homeDirectory, '.cache') : undefined);
2597
-
2598
- exports.runtime = env.XDG_RUNTIME_DIR || undefined;
2599
-
2600
- exports.dataDirs = (env.XDG_DATA_DIRS || '/usr/local/share/:/usr/share/').split(':');
2601
-
2602
- if (exports.data) {
2603
- exports.dataDirs.unshift(exports.data);
2604
- }
2605
-
2606
- exports.configDirs = (env.XDG_CONFIG_DIRS || '/etc/xdg').split(':');
2607
-
2608
- if (exports.config) {
2609
- exports.configDirs.unshift(exports.config);
2610
- }
2611
- } (xdgBasedir$1));
2612
-
2613
- const fs = require$$0$1.promises;
2614
- const path = require$$0;
2615
- const df = dfExports$1;
2616
- const mountPoint = mountPoint$1;
2617
- const userHome = userHome$1;
2618
- const xdgBasedir = xdgBasedir$1;
2619
-
2620
- const check = async filePath => {
2621
- const topuid = `${filePath}-${process.getuid()}`;
2622
- const stickyBitMode = 17407;
2623
-
2624
- try {
2625
- const stats = await fs.lstat(filePath);
2626
-
2627
- if (stats.isSymbolicLink() || stats.mode !== stickyBitMode) {
2628
- return topuid;
2629
- }
2630
-
2631
- return path.join(filePath, String(process.getuid()));
2632
- } catch (error) {
2633
- if (error.code === 'ENOENT') {
2634
- return topuid;
2635
- }
2636
-
2637
- return path.join(xdgBasedir.data, 'Trash');
2638
- }
2639
- };
2640
-
2641
- xdgTrashdir$1.exports = async filePath => {
2642
- if (process.platform !== 'linux') {
2643
- return Promise.reject(new Error('Only Linux systems are supported'));
2644
- }
2645
-
2646
- if (!filePath) {
2647
- return Promise.resolve(path.join(xdgBasedir.data, 'Trash'));
2648
- }
2649
-
2650
- const [homeMountPoint, fileMountPoint] = await Promise.all([
2651
- mountPoint(userHome),
2652
- // Ignore errors in case `file` is a dangling symlink
2653
- mountPoint(filePath).catch(() => {})
2654
- ]);
2655
-
2656
- if (!fileMountPoint || fileMountPoint === homeMountPoint) {
2657
- return path.join(xdgBasedir.data, 'Trash');
2658
- }
2659
-
2660
- return check(path.join(fileMountPoint, '.Trash'));
2661
- };
2662
-
2663
- xdgTrashdir$1.exports.all = async () => {
2664
- if (process.platform !== 'linux') {
2665
- return Promise.reject(new Error('Only Linux systems are supported'));
2666
- }
2667
-
2668
- return Promise.all((await df()).map(fileSystem => {
2669
- if (fileSystem.mountpoint === '/') {
2670
- return path.join(xdgBasedir.data, 'Trash');
2671
- }
2672
-
2673
- return check(path.join(fileSystem.mountpoint, '.Trash'));
2674
- }));
2675
- };
2676
-
2677
- var xdgTrashdirExports = xdgTrashdir$1.exports;
2678
- var xdgTrashdir = /*@__PURE__*/index.getDefaultExportFromCjs(xdgTrashdirExports);
2679
-
2680
- async function pMap(
2681
- iterable,
2682
- mapper,
2683
- {
2684
- concurrency = Number.POSITIVE_INFINITY,
2685
- stopOnError = true,
2686
- signal,
2687
- } = {},
2688
- ) {
2689
- return new Promise((resolve, reject_) => {
2690
- if (iterable[Symbol.iterator] === undefined && iterable[Symbol.asyncIterator] === undefined) {
2691
- throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof iterable})`);
2692
- }
2693
-
2694
- if (typeof mapper !== 'function') {
2695
- throw new TypeError('Mapper function is required');
2696
- }
2697
-
2698
- if (!((Number.isSafeInteger(concurrency) && concurrency >= 1) || concurrency === Number.POSITIVE_INFINITY)) {
2699
- throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${concurrency}\` (${typeof concurrency})`);
2700
- }
2701
-
2702
- const result = [];
2703
- const errors = [];
2704
- const skippedIndexesMap = new Map();
2705
- let isRejected = false;
2706
- let isResolved = false;
2707
- let isIterableDone = false;
2708
- let resolvingCount = 0;
2709
- let currentIndex = 0;
2710
- const iterator = iterable[Symbol.iterator] === undefined ? iterable[Symbol.asyncIterator]() : iterable[Symbol.iterator]();
2711
-
2712
- const reject = reason => {
2713
- isRejected = true;
2714
- isResolved = true;
2715
- reject_(reason);
2716
- };
2717
-
2718
- if (signal) {
2719
- if (signal.aborted) {
2720
- reject(signal.reason);
2721
- }
2722
-
2723
- signal.addEventListener('abort', () => {
2724
- reject(signal.reason);
2725
- });
2726
- }
2727
-
2728
- const next = async () => {
2729
- if (isResolved) {
2730
- return;
2731
- }
2732
-
2733
- const nextItem = await iterator.next();
2734
-
2735
- const index = currentIndex;
2736
- currentIndex++;
2737
-
2738
- // Note: `iterator.next()` can be called many times in parallel.
2739
- // This can cause multiple calls to this `next()` function to
2740
- // receive a `nextItem` with `done === true`.
2741
- // The shutdown logic that rejects/resolves must be protected
2742
- // so it runs only one time as the `skippedIndex` logic is
2743
- // non-idempotent.
2744
- if (nextItem.done) {
2745
- isIterableDone = true;
2746
-
2747
- if (resolvingCount === 0 && !isResolved) {
2748
- if (!stopOnError && errors.length > 0) {
2749
- reject(new AggregateError(errors)); // eslint-disable-line unicorn/error-message
2750
- return;
2751
- }
2752
-
2753
- isResolved = true;
2754
-
2755
- if (skippedIndexesMap.size === 0) {
2756
- resolve(result);
2757
- return;
2758
- }
2759
-
2760
- const pureResult = [];
2761
-
2762
- // Support multiple `pMapSkip`'s.
2763
- for (const [index, value] of result.entries()) {
2764
- if (skippedIndexesMap.get(index) === pMapSkip) {
2765
- continue;
2766
- }
2767
-
2768
- pureResult.push(value);
2769
- }
2770
-
2771
- resolve(pureResult);
2772
- }
2773
-
2774
- return;
2775
- }
2776
-
2777
- resolvingCount++;
2778
-
2779
- // Intentionally detached
2780
- (async () => {
2781
- try {
2782
- const element = await nextItem.value;
2783
-
2784
- if (isResolved) {
2785
- return;
2786
- }
2787
-
2788
- const value = await mapper(element, index);
2789
-
2790
- // Use Map to stage the index of the element.
2791
- if (value === pMapSkip) {
2792
- skippedIndexesMap.set(index, value);
2793
- }
2794
-
2795
- result[index] = value;
2796
-
2797
- resolvingCount--;
2798
- await next();
2799
- } catch (error) {
2800
- if (stopOnError) {
2801
- reject(error);
2802
- } else {
2803
- errors.push(error);
2804
- resolvingCount--;
2805
-
2806
- // In that case we can't really continue regardless of `stopOnError` state
2807
- // since an iterable is likely to continue throwing after it throws once.
2808
- // If we continue calling `next()` indefinitely we will likely end up
2809
- // in an infinite loop of failed iteration.
2810
- try {
2811
- await next();
2812
- } catch (error) {
2813
- reject(error);
2814
- }
2815
- }
2816
- }
2817
- })();
2818
- };
2819
-
2820
- // Create the concurrent runners in a detached (non-awaited)
2821
- // promise. We need this so we can await the `next()` calls
2822
- // to stop creating runners before hitting the concurrency limit
2823
- // if the iterable has already been marked as done.
2824
- // NOTE: We *must* do this for async iterators otherwise we'll spin up
2825
- // infinite `next()` calls by default and never start the event loop.
2826
- (async () => {
2827
- for (let index = 0; index < concurrency; index++) {
2828
- try {
2829
- // eslint-disable-next-line no-await-in-loop
2830
- await next();
2831
- } catch (error) {
2832
- reject(error);
2833
- break;
2834
- }
2835
-
2836
- if (isIterableDone || isRejected) {
2837
- break;
2838
- }
2839
- }
2840
- })();
2841
- });
2842
- }
2843
-
2844
- const pMapSkip = Symbol('skip');
2845
-
2846
- async function pathExists(path) {
2847
- try {
2848
- await fs$3.promises.access(path);
2849
- return true;
2850
- } catch {
2851
- return false;
2852
- }
2853
- }
2854
-
2855
- const resolvePath = (cwd, sourcePath, destinationPath) => {
2856
- sourcePath = path$5.resolve(cwd, sourcePath);
2857
- destinationPath = path$5.resolve(cwd, destinationPath);
2858
-
2859
- return {
2860
- sourcePath,
2861
- destinationPath,
2862
- };
2863
- };
2864
-
2865
- const validatePathsExist = (sourcePath, destinationPath, suffix = 'Path') => {
2866
- if (!sourcePath || !destinationPath) {
2867
- throw new TypeError(`\`source${suffix}\` and \`destination${suffix}\` required`);
2868
- }
2869
- };
2870
-
2871
- const validateSameDirectory = (source, destination) => {
2872
- if (path$5.dirname(source) !== path$5.dirname(destination)) {
2873
- throw new Error('`source` and `destination` must be in the same directory');
2874
- }
2875
- };
2876
-
2877
- const _moveFile = async (sourcePath, destinationPath, {overwrite = true, cwd = process$2.cwd(), directoryMode, validateDirectory = false} = {}) => {
2878
- if (cwd) {
2879
- ({sourcePath, destinationPath} = resolvePath(cwd, sourcePath, destinationPath));
2880
- }
2881
-
2882
- if (validateDirectory) {
2883
- validateSameDirectory(sourcePath, destinationPath);
2884
- }
2885
-
2886
- if (!overwrite && await pathExists(destinationPath)) {
2887
- throw new Error(`The destination file exists: ${destinationPath}`);
2888
- }
2889
-
2890
- await fs$3.promises.mkdir(path$5.dirname(destinationPath), {
2891
- recursive: true,
2892
- mode: directoryMode,
2893
- });
2894
-
2895
- try {
2896
- await fs$3.promises.rename(sourcePath, destinationPath);
2897
- } catch (error) {
2898
- if (error.code === 'EXDEV') {
2899
- await fs$3.promises.copyFile(sourcePath, destinationPath);
2900
- await fs$3.promises.unlink(sourcePath);
2901
- } else {
2902
- throw error;
2903
- }
2904
- }
2905
- };
2906
-
2907
- async function moveFile(sourcePath, destinationPath, options) {
2908
- validatePathsExist(sourcePath, destinationPath);
2909
- return _moveFile(sourcePath, destinationPath, options);
2910
- }
2911
-
2912
- let ProcfsError$1 = class ProcfsError extends Error {
2913
- constructor(code, message, sourceError) {
2914
- super(message);
2915
- this.name = 'ProcfsError';
2916
- this.code = code;
2917
- if (sourceError !== undefined) {
2918
- this.sourceError = sourceError;
2919
- }
2920
- }
2921
- };
2922
-
2923
- ProcfsError$1.ERR_PARSING_FAILED = 'EPARSE';
2924
- ProcfsError$1.ERR_UNKNOWN = 'EUNKNOWN';
2925
- ProcfsError$1.ERR_NOT_FOUND = 'ENOENT';
2926
-
2927
- ProcfsError$1.parsingError = (src, msg) => {
2928
- let e = new ProcfsError$1(ProcfsError$1.ERR_PARSING_FAILED, `Parsing failed: ${msg}`);
2929
- e.sourceText = src;
2930
- return e;
2931
- };
2932
-
2933
- ProcfsError$1.generic = err => {
2934
- /* istanbul ignore next should not ever happen */
2935
- if (err instanceof ProcfsError$1) {
2936
- return err;
2937
- }
2938
-
2939
- switch (err.code) {
2940
- case 'ENOENT':
2941
- return new ProcfsError$1(ProcfsError$1.ERR_NOT_FOUND, 'File not found', err);
2942
- /* istanbul ignore next should not ever happen*/
2943
- default:
2944
- return new ProcfsError$1(ProcfsError$1.ERR_UNKNOWN, `Unknown error: ${err.message}`, err);
2945
- }
2946
- };
2947
-
2948
- var procfsError = ProcfsError$1;
2949
-
2950
- const trim = str => str.trim();
2951
-
2952
- class Parsers {}
2953
-
2954
- const parsers$1 = new Parsers();
2955
-
2956
- for (let name of [
2957
- 'cgroups',
2958
- 'config',
2959
- 'cpuinfo',
2960
- 'devices',
2961
- 'diskstats',
2962
- 'filesystems',
2963
- 'loadavg',
2964
- 'meminfo',
2965
- 'partitions',
2966
- 'processAutogroup',
2967
- 'processCgroups',
2968
- 'processCmdline',
2969
- 'processEnviron',
2970
- 'processes',
2971
- 'processExe',
2972
- 'processFd',
2973
- 'processFdinfo',
2974
- 'processFds',
2975
- 'processGidMap',
2976
- 'processIo',
2977
- 'processLimits',
2978
- 'processMountinfo',
2979
- 'processNetDev',
2980
- 'processNetTcp4',
2981
- 'processNetTcp6',
2982
- 'processNetUdp4',
2983
- 'processNetUdp6',
2984
- 'processNetUnix',
2985
- 'processNetWireless',
2986
- 'processStat',
2987
- 'processStatm',
2988
- 'processStatus',
2989
- 'processThreads',
2990
- 'processUidMap',
2991
- 'stat',
2992
- 'swaps',
2993
- 'uptime',
2994
- ]) {
2995
- Object.defineProperty(Parsers.prototype, name, {
2996
- get: function () { // eslint-disable-line object-shorthand
2997
- let value = index.commonjsRequire(`./parsers/${name}`);
2998
- Object.defineProperty(this, name, {value});
2999
- return value;
3000
- },
3001
- });
3002
- }
3003
-
3004
- parsers$1.cmdline = trim;
3005
- parsers$1.processComm = trim;
3006
- parsers$1.processCpuset = trim;
3007
- parsers$1.processOomScore = src => parseInt(src);
3008
- parsers$1.processTimerslackNs = src => parseInt(src);
3009
- parsers$1.version = trim;
3010
- parsers$1.processCwd = src => src;
3011
- parsers$1.processPersonality = src => parseInt(src, 16);
3012
-
3013
- var parsers_1 = parsers$1;
3014
-
3015
- const {
3016
- readlinkSync,
3017
- readdirSync,
3018
- openSync,
3019
- readSync,
3020
- closeSync,
3021
- readFileSync,
3022
- existsSync,
3023
- } = require$$0$1;
3024
-
3025
- const tmpBufMinLen = 4096 * 2;
3026
- const tmpBufMaxLen = 4096 * 8;
3027
-
3028
- let tmpBuf = Buffer.allocUnsafeSlow(tmpBufMinLen);
3029
-
3030
- const read$1 = path => {
3031
- const fd = openSync(path, 'r', 0o666);
3032
- let pos = 0;
3033
- let bytesRead;
3034
- let buf = tmpBuf;
3035
- let length = buf.length;
3036
- do {
3037
- bytesRead = readSync(fd, buf, pos, buf.length - pos, null);
3038
- pos += bytesRead;
3039
- if (pos === tmpBuf.length) {
3040
- length = length << 1;
3041
- let newBuf = Buffer.allocUnsafeSlow(length);
3042
-
3043
- if (length <= tmpBufMaxLen) {
3044
- tmpBuf = newBuf;
3045
- }
3046
-
3047
- buf.copy(newBuf);
3048
- buf = newBuf;
3049
- }
3050
- } while (bytesRead !== 0);
3051
- closeSync(fd);
3052
- return buf.toString('utf8', 0, pos);
3053
- };
3054
-
3055
- const readIdList = path => {
3056
- let ls = readdirSync(path);
3057
- for (let i = 0; i < ls.length; i++) {
3058
- ls[i] = parseInt(ls[i]);
3059
- }
3060
- return ls;
3061
- };
3062
-
3063
- const readBuffer$1 = readFileSync;
3064
- const exists = existsSync;
3065
- const readdir$1 = readdirSync;
3066
-
3067
- const devIdGetMinor$1 = devId => (((devId >> 20) << 8) | (devId & 0xFF));
3068
- const devIdGetMajor$1 = devId => ((devId >> 8) & 0xFF);
3069
- const devIdFromMajorMinor$1 = (major, minor) => (((minor >> 8) << 20) | ((major & 0xFF) << 8) | (minor & 0xFF));
3070
-
3071
- var utils = {
3072
- read: read$1,
3073
- readLink: readlinkSync,
3074
- readIdList,
3075
- readBuffer: readBuffer$1,
3076
- exists,
3077
- readdir: readdir$1,
3078
-
3079
- devIdGetMinor: devIdGetMinor$1,
3080
- devIdGetMajor: devIdGetMajor$1,
3081
- devIdFromMajorMinor: devIdFromMajorMinor$1,
3082
- };
3083
-
3084
- const ProcfsError = procfsError;
3085
- const parsers = parsers_1;
3086
- const {
3087
- read,
3088
- readLink,
3089
- readBuffer,
3090
- readdir,
3091
- devIdGetMinor,
3092
- devIdGetMajor,
3093
- devIdFromMajorMinor,
3094
- } = utils;
3095
-
3096
- class Procfs {
3097
- constructor(root) {
3098
- if (root === undefined) {
3099
- root = '/proc';
3100
- }
3101
- this.root = root;
3102
- this.rootSlash = `${root}/`;
3103
- }
3104
-
3105
- processes() {
3106
- try {
3107
- return parsers.processes(readdir(this.root));
3108
- } catch (error) {
3109
- /* istanbul ignore next should not ever happen when procfs exists */
3110
- throw ProcfsError.generic(error);
3111
- }
3112
- }
3113
-
3114
- processFds(pid) {
3115
- if (pid !== undefined && (!Number.isInteger(pid) || pid <= 0)) {
3116
- throw new TypeError('pid');
3117
- }
3118
- try {
3119
- return parsers.processFds(readdir(`${this.rootSlash}${pid === undefined ? 'self' : pid}/fd`));
3120
- } catch (error) {
3121
- throw ProcfsError.generic(error);
3122
- }
3123
- }
3124
-
3125
- processThreads(pid) {
3126
- if (pid !== undefined && (!Number.isInteger(pid) || pid <= 0)) {
3127
- throw new TypeError('pid');
3128
- }
3129
- try {
3130
- return parsers.processThreads(readdir(`${this.rootSlash}${pid === undefined ? 'self' : pid}/task`));
3131
- } catch (error) {
3132
- throw ProcfsError.generic(error);
3133
- }
3134
- }
3135
-
3136
- processFdinfo(fd, pid) {
3137
- if (pid !== undefined && !(Number.isInteger(pid) && pid >= 0)) {
3138
- throw new TypeError('pid');
3139
- }
3140
- if (!Number.isInteger(fd) || fd <= 0) {
3141
- throw new TypeError('fd');
3142
- }
3143
- try {
3144
- return parsers.processFdinfo(read(`${this.rootSlash}${pid === undefined ? 'self' : pid}/fdinfo/${fd}`));
3145
- } catch (error) {
3146
- throw ProcfsError.generic(error);
3147
- }
3148
- }
3149
-
3150
- processFd(fd, pid) {
3151
- if (pid !== undefined && !(Number.isInteger(pid) && pid >= 0)) {
3152
- throw new TypeError('pid');
3153
- }
3154
- if (!Number.isInteger(fd) || fd <= 0) {
3155
- throw new TypeError('fd');
3156
- }
3157
- try {
3158
- return parsers.processFd(readLink(`${this.rootSlash}${pid === undefined ? 'self' : pid}/fd/${fd}`));
3159
- } catch (error) {
3160
- throw ProcfsError.generic(error);
3161
- }
3162
- }
3163
-
3164
- config() {
3165
- try {
3166
- return parsers.config(readBuffer(`${this.rootSlash}config.gz`));
3167
- } catch (error) {
3168
- /* istanbul ignore next should not ever happen when procfs exists and kernel properly configured */
3169
- throw ProcfsError.generic(error);
3170
- }
3171
- }
3172
- }
3173
-
3174
- Procfs.prototype.devIdGetMinor = devIdGetMinor;
3175
- Procfs.prototype.devIdGetMajor = devIdGetMajor;
3176
- Procfs.prototype.devIdFromMajorMinor = devIdFromMajorMinor;
3177
-
3178
- for (let [name, path] of [
3179
- ['processExe', '/exe'],
3180
- ['processCwd', '/cwd'],
3181
- ]) {
3182
- Procfs.prototype[name] = function (pid) {
3183
- if (pid !== undefined && !(Number.isInteger(pid) && pid >= 0)) {
3184
- throw new TypeError('pid');
3185
- }
3186
- try {
3187
- return parsers[name](readLink(`${this.rootSlash}${pid === undefined ? 'self' : pid}${path}`));
3188
- } catch (error) {
3189
- throw ProcfsError.generic(error);
3190
- }
3191
- };
3192
- }
3193
-
3194
- for (let [name, path] of [
3195
- ['processMountinfo', '/mountinfo'],
3196
- ['processIo', '/io'],
3197
- ['processUidMap', '/uid_map'],
3198
- ['processGidMap', '/gid_map'],
3199
- ['processEnviron', '/environ'],
3200
- ['processOomScore', '/oom_score'],
3201
- ['processTimerslackNs', '/timerslack_ns'],
3202
- ['processCmdline', '/cmdline'],
3203
- ['processAutogroup', '/autogroup'],
3204
- ['processStatm', '/statm'],
3205
- ['processComm', '/comm'],
3206
- ['processPersonality', '/personality'],
3207
- ['processCgroups', '/cgroup'],
3208
- ['processCpuset', '/cpuset'],
3209
- ['processLimits', '/limits'],
3210
- ['processStat', '/stat'],
3211
- ['processStatus', '/status'],
3212
- ['processNetDev', '/net/dev'],
3213
- ['processNetWireless', '/net/wireless'],
3214
- ['processNetUnix', '/net/unix'],
3215
- ['processNetTcp4', '/net/tcp'],
3216
- ['processNetTcp6', '/net/tcp6'],
3217
- ['processNetUdp4', '/net/udp'],
3218
- ['processNetUdp6', '/net/udp6'],
3219
- ]) {
3220
- Procfs.prototype[name] = function (pid) {
3221
- if (pid !== undefined && !(Number.isInteger(pid) && pid >= 0)) {
3222
- throw new TypeError('pid');
3223
- }
3224
- try {
3225
- return parsers[name](read(`${this.rootSlash}${pid === undefined ? 'self' : pid}${path}`));
3226
- } catch (error) {
3227
- throw ProcfsError.generic(error);
3228
- }
3229
- };
3230
- }
3231
-
3232
- for (let name of [
3233
- 'cpuinfo',
3234
- 'loadavg',
3235
- 'uptime',
3236
- 'version',
3237
- 'cmdline',
3238
- 'swaps',
3239
- 'stat',
3240
- 'devices',
3241
- 'filesystems',
3242
- 'diskstats',
3243
- 'partitions',
3244
- 'meminfo',
3245
- 'cgroups',
3246
- ]) {
3247
- Procfs.prototype[name] = function () {
3248
- try {
3249
- return parsers[name](read(this.rootSlash + name));
3250
- } catch (error) {
3251
- /* istanbul ignore next should not ever happen when procfs exists */
3252
- throw ProcfsError.generic(error);
3253
- }
3254
- };
3255
- }
3256
-
3257
- for (let [name, parser, path] of [
3258
- ['netDev', 'processNetDev', 'net/dev'],
3259
- ['netWireless', 'processNetWireless', 'net/wireless'],
3260
- ['netUnix', 'processNetUnix', 'net/unix'],
3261
- ['netTcp4', 'processNetTcp4', 'net/tcp'],
3262
- ['netTcp6', 'processNetTcp6', 'net/tcp6'],
3263
- ['netUdp4', 'processNetUdp4', 'net/udp'],
3264
- ['netUdp6', 'processNetUdp6', 'net/udp6'],
3265
- ]) {
3266
- Procfs.prototype[name] = function () {
3267
- try {
3268
- return parsers[parser](read(this.rootSlash + path));
3269
- } catch (error) {
3270
- /* istanbul ignore next should not ever happen when procfs exists */
3271
- throw ProcfsError.generic(error);
3272
- }
3273
- };
3274
- }
3275
-
3276
- const procfs = new Procfs();
3277
- var procfs_1 = {
3278
- procfs,
3279
- Procfs,
3280
- ProcfsError,
3281
- };
3282
-
3283
- // Educated guess, values of 16 to 64 seem to be optimal for modern SSD, 8-16 and 64-128 can be a bit slower.
3284
- // We should be ok as long as ssdCount <= cpuCount <= ssdCount*16.
3285
- // For slower media this is not as important and we rely on OS handling it for us.
3286
- const concurrency = os$3.cpus().length * 8;
3287
-
3288
- const pad = number => number < 10 ? '0' + number : number;
3289
-
3290
- const getDeletionDate = date => date.getFullYear()
3291
- + '-' + pad(date.getMonth() + 1)
3292
- + '-' + pad(date.getDate())
3293
- + 'T' + pad(date.getHours())
3294
- + ':' + pad(date.getMinutes())
3295
- + ':' + pad(date.getSeconds());
3296
-
3297
- const trash = async (filePath, trashPaths) => {
3298
- const name = crypto.randomUUID();
3299
- const destination = path$5.join(trashPaths.filesPath, name);
3300
- const trashInfoPath = path$5.join(trashPaths.infoPath, `${name}.trashinfo`);
3301
-
3302
- const trashInfoData = `[Trash Info]\nPath=${filePath.replaceAll(/\s/g, '%20')}\nDeletionDate=${getDeletionDate(new Date())}`;
3303
-
3304
- await fs$3.promises.writeFile(trashInfoPath, trashInfoData);
3305
- await moveFile(filePath, destination);
3306
-
3307
- return {
3308
- path: destination,
3309
- info: trashInfoPath,
3310
- };
3311
- };
3312
-
3313
- async function linux(paths) {
3314
- const mountPointMap = new Map();
3315
-
3316
- for (const mountInfo of Object.values(procfs_1.procfs.processMountinfo())) {
3317
- // Filter out irrelevant drives (that start with `/snap`, `/run`, etc).
3318
- if (/^\/(snap|var\/snap|run|sys|proc|dev)($|\/)/.test(mountInfo.mountPoint)) {
3319
- continue;
3320
- }
3321
-
3322
- // Keep the first one if there are multiple `devId`.
3323
- if (!mountPointMap.has(mountInfo.devId)) {
3324
- mountPointMap.set(mountInfo.devId, mountInfo.mountPoint);
3325
- }
3326
- }
3327
-
3328
- const trashPathsCache = new Map();
3329
-
3330
- const getDeviceTrashPaths = async developmentId => {
3331
- let trashPathsPromise = trashPathsCache.get(developmentId);
3332
- if (trashPathsPromise === undefined) {
3333
- trashPathsPromise = (async () => {
3334
- const trashPath = await xdgTrashdir(mountPointMap.get(developmentId));
3335
- const paths = {
3336
- filesPath: path$5.join(trashPath, 'files'),
3337
- infoPath: path$5.join(trashPath, 'info'),
3338
- };
3339
- await fs$3.promises.mkdir(paths.filesPath, {mode: 0o700, recursive: true});
3340
- await fs$3.promises.mkdir(paths.infoPath, {mode: 0o700, recursive: true});
3341
- return paths;
3342
- })();
3343
- trashPathsCache.set(developmentId, trashPathsPromise);
3344
- }
3345
-
3346
- return trashPathsPromise;
3347
- };
3348
-
3349
- return pMap(paths, async filePath => {
3350
- const stats = await fs$3.promises.lstat(filePath);
3351
- const trashPaths = await getDeviceTrashPaths(stats.dev);
3352
- return trash(filePath, trashPaths);
3353
- }, {concurrency});
3354
- }
3355
-
3356
- exports.default = linux;