You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1677 lines
36 KiB
1677 lines
36 KiB
import require$$0 from 'fs';
|
|
import g from 'path';
|
|
import util from 'util';
|
|
import require$$0$2 from 'child_process';
|
|
import { p as pathKey, s as signalExit, m as mergeStream$1, g as getStream$1, c as crossSpawn$1 } from './vendor-index.7a2cebfe.js';
|
|
import { o as onetime$1 } from './vendor-index.9c919048.js';
|
|
import require$$0$1 from 'os';
|
|
import './vendor-_commonjsHelpers.addc3445.js';
|
|
import 'assert';
|
|
import 'events';
|
|
import 'buffer';
|
|
import 'stream';
|
|
|
|
var findUp$1 = {exports: {}};
|
|
|
|
var locatePath = {exports: {}};
|
|
|
|
class Node {
|
|
/// value;
|
|
/// next;
|
|
|
|
constructor(value) {
|
|
this.value = value;
|
|
|
|
// TODO: Remove this when targeting Node.js 12.
|
|
this.next = undefined;
|
|
}
|
|
}
|
|
|
|
class Queue$1 {
|
|
// TODO: Use private class fields when targeting Node.js 12.
|
|
// #_head;
|
|
// #_tail;
|
|
// #_size;
|
|
|
|
constructor() {
|
|
this.clear();
|
|
}
|
|
|
|
enqueue(value) {
|
|
const node = new Node(value);
|
|
|
|
if (this._head) {
|
|
this._tail.next = node;
|
|
this._tail = node;
|
|
} else {
|
|
this._head = node;
|
|
this._tail = node;
|
|
}
|
|
|
|
this._size++;
|
|
}
|
|
|
|
dequeue() {
|
|
const current = this._head;
|
|
if (!current) {
|
|
return;
|
|
}
|
|
|
|
this._head = this._head.next;
|
|
this._size--;
|
|
return current.value;
|
|
}
|
|
|
|
clear() {
|
|
this._head = undefined;
|
|
this._tail = undefined;
|
|
this._size = 0;
|
|
}
|
|
|
|
get size() {
|
|
return this._size;
|
|
}
|
|
|
|
* [Symbol.iterator]() {
|
|
let current = this._head;
|
|
|
|
while (current) {
|
|
yield current.value;
|
|
current = current.next;
|
|
}
|
|
}
|
|
}
|
|
|
|
var yoctoQueue = Queue$1;
|
|
|
|
const Queue = yoctoQueue;
|
|
|
|
const pLimit$1 = concurrency => {
|
|
if (!((Number.isInteger(concurrency) || concurrency === Infinity) && concurrency > 0)) {
|
|
throw new TypeError('Expected `concurrency` to be a number from 1 and up');
|
|
}
|
|
|
|
const queue = new Queue();
|
|
let activeCount = 0;
|
|
|
|
const next = () => {
|
|
activeCount--;
|
|
|
|
if (queue.size > 0) {
|
|
queue.dequeue()();
|
|
}
|
|
};
|
|
|
|
const run = async (fn, resolve, ...args) => {
|
|
activeCount++;
|
|
|
|
const result = (async () => fn(...args))();
|
|
|
|
resolve(result);
|
|
|
|
try {
|
|
await result;
|
|
} catch {}
|
|
|
|
next();
|
|
};
|
|
|
|
const enqueue = (fn, resolve, ...args) => {
|
|
queue.enqueue(run.bind(null, fn, resolve, ...args));
|
|
|
|
(async () => {
|
|
// This function needs to wait until the next microtask before comparing
|
|
// `activeCount` to `concurrency`, because `activeCount` is updated asynchronously
|
|
// when the run function is dequeued and called. The comparison in the if-statement
|
|
// needs to happen asynchronously as well to get an up-to-date value for `activeCount`.
|
|
await Promise.resolve();
|
|
|
|
if (activeCount < concurrency && queue.size > 0) {
|
|
queue.dequeue()();
|
|
}
|
|
})();
|
|
};
|
|
|
|
const generator = (fn, ...args) => new Promise(resolve => {
|
|
enqueue(fn, resolve, ...args);
|
|
});
|
|
|
|
Object.defineProperties(generator, {
|
|
activeCount: {
|
|
get: () => activeCount
|
|
},
|
|
pendingCount: {
|
|
get: () => queue.size
|
|
},
|
|
clearQueue: {
|
|
value: () => {
|
|
queue.clear();
|
|
}
|
|
}
|
|
});
|
|
|
|
return generator;
|
|
};
|
|
|
|
var pLimit_1 = pLimit$1;
|
|
|
|
const pLimit = pLimit_1;
|
|
|
|
class EndError extends Error {
|
|
constructor(value) {
|
|
super();
|
|
this.value = value;
|
|
}
|
|
}
|
|
|
|
// The input can also be a promise, so we await it
|
|
const testElement = async (element, tester) => tester(await element);
|
|
|
|
// The input can also be a promise, so we `Promise.all()` them both
|
|
const finder = async element => {
|
|
const values = await Promise.all(element);
|
|
if (values[1] === true) {
|
|
throw new EndError(values[0]);
|
|
}
|
|
|
|
return false;
|
|
};
|
|
|
|
const pLocate$1 = async (iterable, tester, options) => {
|
|
options = {
|
|
concurrency: Infinity,
|
|
preserveOrder: true,
|
|
...options
|
|
};
|
|
|
|
const limit = pLimit(options.concurrency);
|
|
|
|
// Start all the promises concurrently with optional limit
|
|
const items = [...iterable].map(element => [element, limit(testElement, element, tester)]);
|
|
|
|
// Check the promises either serially or concurrently
|
|
const checkLimit = pLimit(options.preserveOrder ? 1 : Infinity);
|
|
|
|
try {
|
|
await Promise.all(items.map(element => checkLimit(finder, element)));
|
|
} catch (error) {
|
|
if (error instanceof EndError) {
|
|
return error.value;
|
|
}
|
|
|
|
throw error;
|
|
}
|
|
};
|
|
|
|
var pLocate_1 = pLocate$1;
|
|
|
|
const path$1 = g;
|
|
const fs$1 = require$$0;
|
|
const {promisify: promisify$1} = util;
|
|
const pLocate = pLocate_1;
|
|
|
|
const fsStat = promisify$1(fs$1.stat);
|
|
const fsLStat = promisify$1(fs$1.lstat);
|
|
|
|
const typeMappings = {
|
|
directory: 'isDirectory',
|
|
file: 'isFile'
|
|
};
|
|
|
|
function checkType({type}) {
|
|
if (type in typeMappings) {
|
|
return;
|
|
}
|
|
|
|
throw new Error(`Invalid type specified: ${type}`);
|
|
}
|
|
|
|
const matchType = (type, stat) => type === undefined || stat[typeMappings[type]]();
|
|
|
|
locatePath.exports = async (paths, options) => {
|
|
options = {
|
|
cwd: process.cwd(),
|
|
type: 'file',
|
|
allowSymlinks: true,
|
|
...options
|
|
};
|
|
|
|
checkType(options);
|
|
|
|
const statFn = options.allowSymlinks ? fsStat : fsLStat;
|
|
|
|
return pLocate(paths, async path_ => {
|
|
try {
|
|
const stat = await statFn(path$1.resolve(options.cwd, path_));
|
|
return matchType(options.type, stat);
|
|
} catch {
|
|
return false;
|
|
}
|
|
}, options);
|
|
};
|
|
|
|
locatePath.exports.sync = (paths, options) => {
|
|
options = {
|
|
cwd: process.cwd(),
|
|
allowSymlinks: true,
|
|
type: 'file',
|
|
...options
|
|
};
|
|
|
|
checkType(options);
|
|
|
|
const statFn = options.allowSymlinks ? fs$1.statSync : fs$1.lstatSync;
|
|
|
|
for (const path_ of paths) {
|
|
try {
|
|
const stat = statFn(path$1.resolve(options.cwd, path_));
|
|
|
|
if (matchType(options.type, stat)) {
|
|
return path_;
|
|
}
|
|
} catch {}
|
|
}
|
|
};
|
|
|
|
var pathExists = {exports: {}};
|
|
|
|
const fs = require$$0;
|
|
const {promisify} = util;
|
|
|
|
const pAccess = promisify(fs.access);
|
|
|
|
pathExists.exports = async path => {
|
|
try {
|
|
await pAccess(path);
|
|
return true;
|
|
} catch (_) {
|
|
return false;
|
|
}
|
|
};
|
|
|
|
pathExists.exports.sync = path => {
|
|
try {
|
|
fs.accessSync(path);
|
|
return true;
|
|
} catch (_) {
|
|
return false;
|
|
}
|
|
};
|
|
|
|
(function (module) {
|
|
const path = g;
|
|
const locatePath$1 = locatePath.exports;
|
|
const pathExists$1 = pathExists.exports;
|
|
|
|
const stop = Symbol('findUp.stop');
|
|
|
|
module.exports = async (name, options = {}) => {
|
|
let directory = path.resolve(options.cwd || '');
|
|
const {root} = path.parse(directory);
|
|
const paths = [].concat(name);
|
|
|
|
const runMatcher = async locateOptions => {
|
|
if (typeof name !== 'function') {
|
|
return locatePath$1(paths, locateOptions);
|
|
}
|
|
|
|
const foundPath = await name(locateOptions.cwd);
|
|
if (typeof foundPath === 'string') {
|
|
return locatePath$1([foundPath], locateOptions);
|
|
}
|
|
|
|
return foundPath;
|
|
};
|
|
|
|
// eslint-disable-next-line no-constant-condition
|
|
while (true) {
|
|
// eslint-disable-next-line no-await-in-loop
|
|
const foundPath = await runMatcher({...options, cwd: directory});
|
|
|
|
if (foundPath === stop) {
|
|
return;
|
|
}
|
|
|
|
if (foundPath) {
|
|
return path.resolve(directory, foundPath);
|
|
}
|
|
|
|
if (directory === root) {
|
|
return;
|
|
}
|
|
|
|
directory = path.dirname(directory);
|
|
}
|
|
};
|
|
|
|
module.exports.sync = (name, options = {}) => {
|
|
let directory = path.resolve(options.cwd || '');
|
|
const {root} = path.parse(directory);
|
|
const paths = [].concat(name);
|
|
|
|
const runMatcher = locateOptions => {
|
|
if (typeof name !== 'function') {
|
|
return locatePath$1.sync(paths, locateOptions);
|
|
}
|
|
|
|
const foundPath = name(locateOptions.cwd);
|
|
if (typeof foundPath === 'string') {
|
|
return locatePath$1.sync([foundPath], locateOptions);
|
|
}
|
|
|
|
return foundPath;
|
|
};
|
|
|
|
// eslint-disable-next-line no-constant-condition
|
|
while (true) {
|
|
const foundPath = runMatcher({...options, cwd: directory});
|
|
|
|
if (foundPath === stop) {
|
|
return;
|
|
}
|
|
|
|
if (foundPath) {
|
|
return path.resolve(directory, foundPath);
|
|
}
|
|
|
|
if (directory === root) {
|
|
return;
|
|
}
|
|
|
|
directory = path.dirname(directory);
|
|
}
|
|
};
|
|
|
|
module.exports.exists = pathExists$1;
|
|
|
|
module.exports.sync.exists = pathExists$1.sync;
|
|
|
|
module.exports.stop = stop;
|
|
} (findUp$1));
|
|
|
|
var findUp = findUp$1.exports;
|
|
|
|
var execa$1 = {exports: {}};
|
|
|
|
var stripFinalNewline$1 = input => {
|
|
const LF = typeof input === 'string' ? '\n' : '\n'.charCodeAt();
|
|
const CR = typeof input === 'string' ? '\r' : '\r'.charCodeAt();
|
|
|
|
if (input[input.length - 1] === LF) {
|
|
input = input.slice(0, input.length - 1);
|
|
}
|
|
|
|
if (input[input.length - 1] === CR) {
|
|
input = input.slice(0, input.length - 1);
|
|
}
|
|
|
|
return input;
|
|
};
|
|
|
|
var npmRunPath$1 = {exports: {}};
|
|
|
|
(function (module) {
|
|
const path = g;
|
|
const pathKey$1 = pathKey.exports;
|
|
|
|
const npmRunPath = options => {
|
|
options = {
|
|
cwd: process.cwd(),
|
|
path: process.env[pathKey$1()],
|
|
execPath: process.execPath,
|
|
...options
|
|
};
|
|
|
|
let previous;
|
|
let cwdPath = path.resolve(options.cwd);
|
|
const result = [];
|
|
|
|
while (previous !== cwdPath) {
|
|
result.push(path.join(cwdPath, 'node_modules/.bin'));
|
|
previous = cwdPath;
|
|
cwdPath = path.resolve(cwdPath, '..');
|
|
}
|
|
|
|
// Ensure the running `node` binary is used
|
|
const execPathDir = path.resolve(options.cwd, options.execPath, '..');
|
|
result.push(execPathDir);
|
|
|
|
return result.concat(options.path).join(path.delimiter);
|
|
};
|
|
|
|
module.exports = npmRunPath;
|
|
// TODO: Remove this for the next major release
|
|
module.exports.default = npmRunPath;
|
|
|
|
module.exports.env = options => {
|
|
options = {
|
|
env: process.env,
|
|
...options
|
|
};
|
|
|
|
const env = {...options.env};
|
|
const path = pathKey$1({env});
|
|
|
|
options.path = env[path];
|
|
env[path] = module.exports(options);
|
|
|
|
return env;
|
|
};
|
|
} (npmRunPath$1));
|
|
|
|
var main = {};
|
|
|
|
var signals = {};
|
|
|
|
var core = {};
|
|
|
|
Object.defineProperty(core,"__esModule",{value:true});core.SIGNALS=void 0;
|
|
|
|
const SIGNALS=[
|
|
{
|
|
name:"SIGHUP",
|
|
number:1,
|
|
action:"terminate",
|
|
description:"Terminal closed",
|
|
standard:"posix"},
|
|
|
|
{
|
|
name:"SIGINT",
|
|
number:2,
|
|
action:"terminate",
|
|
description:"User interruption with CTRL-C",
|
|
standard:"ansi"},
|
|
|
|
{
|
|
name:"SIGQUIT",
|
|
number:3,
|
|
action:"core",
|
|
description:"User interruption with CTRL-\\",
|
|
standard:"posix"},
|
|
|
|
{
|
|
name:"SIGILL",
|
|
number:4,
|
|
action:"core",
|
|
description:"Invalid machine instruction",
|
|
standard:"ansi"},
|
|
|
|
{
|
|
name:"SIGTRAP",
|
|
number:5,
|
|
action:"core",
|
|
description:"Debugger breakpoint",
|
|
standard:"posix"},
|
|
|
|
{
|
|
name:"SIGABRT",
|
|
number:6,
|
|
action:"core",
|
|
description:"Aborted",
|
|
standard:"ansi"},
|
|
|
|
{
|
|
name:"SIGIOT",
|
|
number:6,
|
|
action:"core",
|
|
description:"Aborted",
|
|
standard:"bsd"},
|
|
|
|
{
|
|
name:"SIGBUS",
|
|
number:7,
|
|
action:"core",
|
|
description:
|
|
"Bus error due to misaligned, non-existing address or paging error",
|
|
standard:"bsd"},
|
|
|
|
{
|
|
name:"SIGEMT",
|
|
number:7,
|
|
action:"terminate",
|
|
description:"Command should be emulated but is not implemented",
|
|
standard:"other"},
|
|
|
|
{
|
|
name:"SIGFPE",
|
|
number:8,
|
|
action:"core",
|
|
description:"Floating point arithmetic error",
|
|
standard:"ansi"},
|
|
|
|
{
|
|
name:"SIGKILL",
|
|
number:9,
|
|
action:"terminate",
|
|
description:"Forced termination",
|
|
standard:"posix",
|
|
forced:true},
|
|
|
|
{
|
|
name:"SIGUSR1",
|
|
number:10,
|
|
action:"terminate",
|
|
description:"Application-specific signal",
|
|
standard:"posix"},
|
|
|
|
{
|
|
name:"SIGSEGV",
|
|
number:11,
|
|
action:"core",
|
|
description:"Segmentation fault",
|
|
standard:"ansi"},
|
|
|
|
{
|
|
name:"SIGUSR2",
|
|
number:12,
|
|
action:"terminate",
|
|
description:"Application-specific signal",
|
|
standard:"posix"},
|
|
|
|
{
|
|
name:"SIGPIPE",
|
|
number:13,
|
|
action:"terminate",
|
|
description:"Broken pipe or socket",
|
|
standard:"posix"},
|
|
|
|
{
|
|
name:"SIGALRM",
|
|
number:14,
|
|
action:"terminate",
|
|
description:"Timeout or timer",
|
|
standard:"posix"},
|
|
|
|
{
|
|
name:"SIGTERM",
|
|
number:15,
|
|
action:"terminate",
|
|
description:"Termination",
|
|
standard:"ansi"},
|
|
|
|
{
|
|
name:"SIGSTKFLT",
|
|
number:16,
|
|
action:"terminate",
|
|
description:"Stack is empty or overflowed",
|
|
standard:"other"},
|
|
|
|
{
|
|
name:"SIGCHLD",
|
|
number:17,
|
|
action:"ignore",
|
|
description:"Child process terminated, paused or unpaused",
|
|
standard:"posix"},
|
|
|
|
{
|
|
name:"SIGCLD",
|
|
number:17,
|
|
action:"ignore",
|
|
description:"Child process terminated, paused or unpaused",
|
|
standard:"other"},
|
|
|
|
{
|
|
name:"SIGCONT",
|
|
number:18,
|
|
action:"unpause",
|
|
description:"Unpaused",
|
|
standard:"posix",
|
|
forced:true},
|
|
|
|
{
|
|
name:"SIGSTOP",
|
|
number:19,
|
|
action:"pause",
|
|
description:"Paused",
|
|
standard:"posix",
|
|
forced:true},
|
|
|
|
{
|
|
name:"SIGTSTP",
|
|
number:20,
|
|
action:"pause",
|
|
description:"Paused using CTRL-Z or \"suspend\"",
|
|
standard:"posix"},
|
|
|
|
{
|
|
name:"SIGTTIN",
|
|
number:21,
|
|
action:"pause",
|
|
description:"Background process cannot read terminal input",
|
|
standard:"posix"},
|
|
|
|
{
|
|
name:"SIGBREAK",
|
|
number:21,
|
|
action:"terminate",
|
|
description:"User interruption with CTRL-BREAK",
|
|
standard:"other"},
|
|
|
|
{
|
|
name:"SIGTTOU",
|
|
number:22,
|
|
action:"pause",
|
|
description:"Background process cannot write to terminal output",
|
|
standard:"posix"},
|
|
|
|
{
|
|
name:"SIGURG",
|
|
number:23,
|
|
action:"ignore",
|
|
description:"Socket received out-of-band data",
|
|
standard:"bsd"},
|
|
|
|
{
|
|
name:"SIGXCPU",
|
|
number:24,
|
|
action:"core",
|
|
description:"Process timed out",
|
|
standard:"bsd"},
|
|
|
|
{
|
|
name:"SIGXFSZ",
|
|
number:25,
|
|
action:"core",
|
|
description:"File too big",
|
|
standard:"bsd"},
|
|
|
|
{
|
|
name:"SIGVTALRM",
|
|
number:26,
|
|
action:"terminate",
|
|
description:"Timeout or timer",
|
|
standard:"bsd"},
|
|
|
|
{
|
|
name:"SIGPROF",
|
|
number:27,
|
|
action:"terminate",
|
|
description:"Timeout or timer",
|
|
standard:"bsd"},
|
|
|
|
{
|
|
name:"SIGWINCH",
|
|
number:28,
|
|
action:"ignore",
|
|
description:"Terminal window size changed",
|
|
standard:"bsd"},
|
|
|
|
{
|
|
name:"SIGIO",
|
|
number:29,
|
|
action:"terminate",
|
|
description:"I/O is available",
|
|
standard:"other"},
|
|
|
|
{
|
|
name:"SIGPOLL",
|
|
number:29,
|
|
action:"terminate",
|
|
description:"Watched event",
|
|
standard:"other"},
|
|
|
|
{
|
|
name:"SIGINFO",
|
|
number:29,
|
|
action:"ignore",
|
|
description:"Request for process information",
|
|
standard:"other"},
|
|
|
|
{
|
|
name:"SIGPWR",
|
|
number:30,
|
|
action:"terminate",
|
|
description:"Device running out of power",
|
|
standard:"systemv"},
|
|
|
|
{
|
|
name:"SIGSYS",
|
|
number:31,
|
|
action:"core",
|
|
description:"Invalid system call",
|
|
standard:"other"},
|
|
|
|
{
|
|
name:"SIGUNUSED",
|
|
number:31,
|
|
action:"terminate",
|
|
description:"Invalid system call",
|
|
standard:"other"}];core.SIGNALS=SIGNALS;
|
|
|
|
var realtime = {};
|
|
|
|
Object.defineProperty(realtime,"__esModule",{value:true});realtime.SIGRTMAX=realtime.getRealtimeSignals=void 0;
|
|
const getRealtimeSignals=function(){
|
|
const length=SIGRTMAX-SIGRTMIN+1;
|
|
return Array.from({length},getRealtimeSignal);
|
|
};realtime.getRealtimeSignals=getRealtimeSignals;
|
|
|
|
const getRealtimeSignal=function(value,index){
|
|
return {
|
|
name:`SIGRT${index+1}`,
|
|
number:SIGRTMIN+index,
|
|
action:"terminate",
|
|
description:"Application-specific signal (realtime)",
|
|
standard:"posix"};
|
|
|
|
};
|
|
|
|
const SIGRTMIN=34;
|
|
const SIGRTMAX=64;realtime.SIGRTMAX=SIGRTMAX;
|
|
|
|
Object.defineProperty(signals,"__esModule",{value:true});signals.getSignals=void 0;var _os$1=require$$0$1;
|
|
|
|
var _core=core;
|
|
var _realtime$1=realtime;
|
|
|
|
|
|
|
|
const getSignals=function(){
|
|
const realtimeSignals=(0, _realtime$1.getRealtimeSignals)();
|
|
const signals=[..._core.SIGNALS,...realtimeSignals].map(normalizeSignal);
|
|
return signals;
|
|
};signals.getSignals=getSignals;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const normalizeSignal=function({
|
|
name,
|
|
number:defaultNumber,
|
|
description,
|
|
action,
|
|
forced=false,
|
|
standard})
|
|
{
|
|
const{
|
|
signals:{[name]:constantSignal}}=
|
|
_os$1.constants;
|
|
const supported=constantSignal!==undefined;
|
|
const number=supported?constantSignal:defaultNumber;
|
|
return {name,number,description,supported,action,forced,standard};
|
|
};
|
|
|
|
Object.defineProperty(main,"__esModule",{value:true});main.signalsByNumber=main.signalsByName=void 0;var _os=require$$0$1;
|
|
|
|
var _signals=signals;
|
|
var _realtime=realtime;
|
|
|
|
|
|
|
|
const getSignalsByName=function(){
|
|
const signals=(0, _signals.getSignals)();
|
|
return signals.reduce(getSignalByName,{});
|
|
};
|
|
|
|
const getSignalByName=function(
|
|
signalByNameMemo,
|
|
{name,number,description,supported,action,forced,standard})
|
|
{
|
|
return {
|
|
...signalByNameMemo,
|
|
[name]:{name,number,description,supported,action,forced,standard}};
|
|
|
|
};
|
|
|
|
const signalsByName$1=getSignalsByName();main.signalsByName=signalsByName$1;
|
|
|
|
|
|
|
|
|
|
const getSignalsByNumber=function(){
|
|
const signals=(0, _signals.getSignals)();
|
|
const length=_realtime.SIGRTMAX+1;
|
|
const signalsA=Array.from({length},(value,number)=>
|
|
getSignalByNumber(number,signals));
|
|
|
|
return Object.assign({},...signalsA);
|
|
};
|
|
|
|
const getSignalByNumber=function(number,signals){
|
|
const signal=findSignalByNumber(number,signals);
|
|
|
|
if(signal===undefined){
|
|
return {};
|
|
}
|
|
|
|
const{name,description,supported,action,forced,standard}=signal;
|
|
return {
|
|
[number]:{
|
|
name,
|
|
number,
|
|
description,
|
|
supported,
|
|
action,
|
|
forced,
|
|
standard}};
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
const findSignalByNumber=function(number,signals){
|
|
const signal=signals.find(({name})=>_os.constants.signals[name]===number);
|
|
|
|
if(signal!==undefined){
|
|
return signal;
|
|
}
|
|
|
|
return signals.find(signalA=>signalA.number===number);
|
|
};
|
|
|
|
const signalsByNumber=getSignalsByNumber();main.signalsByNumber=signalsByNumber;
|
|
|
|
const {signalsByName} = main;
|
|
|
|
const getErrorPrefix = ({timedOut, timeout, errorCode, signal, signalDescription, exitCode, isCanceled}) => {
|
|
if (timedOut) {
|
|
return `timed out after ${timeout} milliseconds`;
|
|
}
|
|
|
|
if (isCanceled) {
|
|
return 'was canceled';
|
|
}
|
|
|
|
if (errorCode !== undefined) {
|
|
return `failed with ${errorCode}`;
|
|
}
|
|
|
|
if (signal !== undefined) {
|
|
return `was killed with ${signal} (${signalDescription})`;
|
|
}
|
|
|
|
if (exitCode !== undefined) {
|
|
return `failed with exit code ${exitCode}`;
|
|
}
|
|
|
|
return 'failed';
|
|
};
|
|
|
|
const makeError$1 = ({
|
|
stdout,
|
|
stderr,
|
|
all,
|
|
error,
|
|
signal,
|
|
exitCode,
|
|
command,
|
|
escapedCommand,
|
|
timedOut,
|
|
isCanceled,
|
|
killed,
|
|
parsed: {options: {timeout}}
|
|
}) => {
|
|
// `signal` and `exitCode` emitted on `spawned.on('exit')` event can be `null`.
|
|
// We normalize them to `undefined`
|
|
exitCode = exitCode === null ? undefined : exitCode;
|
|
signal = signal === null ? undefined : signal;
|
|
const signalDescription = signal === undefined ? undefined : signalsByName[signal].description;
|
|
|
|
const errorCode = error && error.code;
|
|
|
|
const prefix = getErrorPrefix({timedOut, timeout, errorCode, signal, signalDescription, exitCode, isCanceled});
|
|
const execaMessage = `Command ${prefix}: ${command}`;
|
|
const isError = Object.prototype.toString.call(error) === '[object Error]';
|
|
const shortMessage = isError ? `${execaMessage}\n${error.message}` : execaMessage;
|
|
const message = [shortMessage, stderr, stdout].filter(Boolean).join('\n');
|
|
|
|
if (isError) {
|
|
error.originalMessage = error.message;
|
|
error.message = message;
|
|
} else {
|
|
error = new Error(message);
|
|
}
|
|
|
|
error.shortMessage = shortMessage;
|
|
error.command = command;
|
|
error.escapedCommand = escapedCommand;
|
|
error.exitCode = exitCode;
|
|
error.signal = signal;
|
|
error.signalDescription = signalDescription;
|
|
error.stdout = stdout;
|
|
error.stderr = stderr;
|
|
|
|
if (all !== undefined) {
|
|
error.all = all;
|
|
}
|
|
|
|
if ('bufferedData' in error) {
|
|
delete error.bufferedData;
|
|
}
|
|
|
|
error.failed = true;
|
|
error.timedOut = Boolean(timedOut);
|
|
error.isCanceled = isCanceled;
|
|
error.killed = killed && !timedOut;
|
|
|
|
return error;
|
|
};
|
|
|
|
var error = makeError$1;
|
|
|
|
var stdio = {exports: {}};
|
|
|
|
const aliases = ['stdin', 'stdout', 'stderr'];
|
|
|
|
const hasAlias = options => aliases.some(alias => options[alias] !== undefined);
|
|
|
|
const normalizeStdio$1 = options => {
|
|
if (!options) {
|
|
return;
|
|
}
|
|
|
|
const {stdio} = options;
|
|
|
|
if (stdio === undefined) {
|
|
return aliases.map(alias => options[alias]);
|
|
}
|
|
|
|
if (hasAlias(options)) {
|
|
throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${aliases.map(alias => `\`${alias}\``).join(', ')}`);
|
|
}
|
|
|
|
if (typeof stdio === 'string') {
|
|
return stdio;
|
|
}
|
|
|
|
if (!Array.isArray(stdio)) {
|
|
throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof stdio}\``);
|
|
}
|
|
|
|
const length = Math.max(stdio.length, aliases.length);
|
|
return Array.from({length}, (value, index) => stdio[index]);
|
|
};
|
|
|
|
stdio.exports = normalizeStdio$1;
|
|
|
|
// `ipc` is pushed unless it is already present
|
|
stdio.exports.node = options => {
|
|
const stdio = normalizeStdio$1(options);
|
|
|
|
if (stdio === 'ipc') {
|
|
return 'ipc';
|
|
}
|
|
|
|
if (stdio === undefined || typeof stdio === 'string') {
|
|
return [stdio, stdio, stdio, 'ipc'];
|
|
}
|
|
|
|
if (stdio.includes('ipc')) {
|
|
return stdio;
|
|
}
|
|
|
|
return [...stdio, 'ipc'];
|
|
};
|
|
|
|
const os = require$$0$1;
|
|
const onExit = signalExit.exports;
|
|
|
|
const DEFAULT_FORCE_KILL_TIMEOUT = 1000 * 5;
|
|
|
|
// Monkey-patches `childProcess.kill()` to add `forceKillAfterTimeout` behavior
|
|
const spawnedKill$1 = (kill, signal = 'SIGTERM', options = {}) => {
|
|
const killResult = kill(signal);
|
|
setKillTimeout(kill, signal, options, killResult);
|
|
return killResult;
|
|
};
|
|
|
|
const setKillTimeout = (kill, signal, options, killResult) => {
|
|
if (!shouldForceKill(signal, options, killResult)) {
|
|
return;
|
|
}
|
|
|
|
const timeout = getForceKillAfterTimeout(options);
|
|
const t = setTimeout(() => {
|
|
kill('SIGKILL');
|
|
}, timeout);
|
|
|
|
// Guarded because there's no `.unref()` when `execa` is used in the renderer
|
|
// process in Electron. This cannot be tested since we don't run tests in
|
|
// Electron.
|
|
// istanbul ignore else
|
|
if (t.unref) {
|
|
t.unref();
|
|
}
|
|
};
|
|
|
|
const shouldForceKill = (signal, {forceKillAfterTimeout}, killResult) => {
|
|
return isSigterm(signal) && forceKillAfterTimeout !== false && killResult;
|
|
};
|
|
|
|
const isSigterm = signal => {
|
|
return signal === os.constants.signals.SIGTERM ||
|
|
(typeof signal === 'string' && signal.toUpperCase() === 'SIGTERM');
|
|
};
|
|
|
|
const getForceKillAfterTimeout = ({forceKillAfterTimeout = true}) => {
|
|
if (forceKillAfterTimeout === true) {
|
|
return DEFAULT_FORCE_KILL_TIMEOUT;
|
|
}
|
|
|
|
if (!Number.isFinite(forceKillAfterTimeout) || forceKillAfterTimeout < 0) {
|
|
throw new TypeError(`Expected the \`forceKillAfterTimeout\` option to be a non-negative integer, got \`${forceKillAfterTimeout}\` (${typeof forceKillAfterTimeout})`);
|
|
}
|
|
|
|
return forceKillAfterTimeout;
|
|
};
|
|
|
|
// `childProcess.cancel()`
|
|
const spawnedCancel$1 = (spawned, context) => {
|
|
const killResult = spawned.kill();
|
|
|
|
if (killResult) {
|
|
context.isCanceled = true;
|
|
}
|
|
};
|
|
|
|
const timeoutKill = (spawned, signal, reject) => {
|
|
spawned.kill(signal);
|
|
reject(Object.assign(new Error('Timed out'), {timedOut: true, signal}));
|
|
};
|
|
|
|
// `timeout` option handling
|
|
const setupTimeout$1 = (spawned, {timeout, killSignal = 'SIGTERM'}, spawnedPromise) => {
|
|
if (timeout === 0 || timeout === undefined) {
|
|
return spawnedPromise;
|
|
}
|
|
|
|
let timeoutId;
|
|
const timeoutPromise = new Promise((resolve, reject) => {
|
|
timeoutId = setTimeout(() => {
|
|
timeoutKill(spawned, killSignal, reject);
|
|
}, timeout);
|
|
});
|
|
|
|
const safeSpawnedPromise = spawnedPromise.finally(() => {
|
|
clearTimeout(timeoutId);
|
|
});
|
|
|
|
return Promise.race([timeoutPromise, safeSpawnedPromise]);
|
|
};
|
|
|
|
const validateTimeout$1 = ({timeout}) => {
|
|
if (timeout !== undefined && (!Number.isFinite(timeout) || timeout < 0)) {
|
|
throw new TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${timeout}\` (${typeof timeout})`);
|
|
}
|
|
};
|
|
|
|
// `cleanup` option handling
|
|
const setExitHandler$1 = async (spawned, {cleanup, detached}, timedPromise) => {
|
|
if (!cleanup || detached) {
|
|
return timedPromise;
|
|
}
|
|
|
|
const removeExitHandler = onExit(() => {
|
|
spawned.kill();
|
|
});
|
|
|
|
return timedPromise.finally(() => {
|
|
removeExitHandler();
|
|
});
|
|
};
|
|
|
|
var kill = {
|
|
spawnedKill: spawnedKill$1,
|
|
spawnedCancel: spawnedCancel$1,
|
|
setupTimeout: setupTimeout$1,
|
|
validateTimeout: validateTimeout$1,
|
|
setExitHandler: setExitHandler$1
|
|
};
|
|
|
|
const isStream$1 = stream =>
|
|
stream !== null &&
|
|
typeof stream === 'object' &&
|
|
typeof stream.pipe === 'function';
|
|
|
|
isStream$1.writable = stream =>
|
|
isStream$1(stream) &&
|
|
stream.writable !== false &&
|
|
typeof stream._write === 'function' &&
|
|
typeof stream._writableState === 'object';
|
|
|
|
isStream$1.readable = stream =>
|
|
isStream$1(stream) &&
|
|
stream.readable !== false &&
|
|
typeof stream._read === 'function' &&
|
|
typeof stream._readableState === 'object';
|
|
|
|
isStream$1.duplex = stream =>
|
|
isStream$1.writable(stream) &&
|
|
isStream$1.readable(stream);
|
|
|
|
isStream$1.transform = stream =>
|
|
isStream$1.duplex(stream) &&
|
|
typeof stream._transform === 'function';
|
|
|
|
var isStream_1 = isStream$1;
|
|
|
|
const isStream = isStream_1;
|
|
const getStream = getStream$1.exports;
|
|
const mergeStream = mergeStream$1;
|
|
|
|
// `input` option
|
|
const handleInput$1 = (spawned, input) => {
|
|
// Checking for stdin is workaround for https://github.com/nodejs/node/issues/26852
|
|
// @todo remove `|| spawned.stdin === undefined` once we drop support for Node.js <=12.2.0
|
|
if (input === undefined || spawned.stdin === undefined) {
|
|
return;
|
|
}
|
|
|
|
if (isStream(input)) {
|
|
input.pipe(spawned.stdin);
|
|
} else {
|
|
spawned.stdin.end(input);
|
|
}
|
|
};
|
|
|
|
// `all` interleaves `stdout` and `stderr`
|
|
const makeAllStream$1 = (spawned, {all}) => {
|
|
if (!all || (!spawned.stdout && !spawned.stderr)) {
|
|
return;
|
|
}
|
|
|
|
const mixed = mergeStream();
|
|
|
|
if (spawned.stdout) {
|
|
mixed.add(spawned.stdout);
|
|
}
|
|
|
|
if (spawned.stderr) {
|
|
mixed.add(spawned.stderr);
|
|
}
|
|
|
|
return mixed;
|
|
};
|
|
|
|
// On failure, `result.stdout|stderr|all` should contain the currently buffered stream
|
|
const getBufferedData = async (stream, streamPromise) => {
|
|
if (!stream) {
|
|
return;
|
|
}
|
|
|
|
stream.destroy();
|
|
|
|
try {
|
|
return await streamPromise;
|
|
} catch (error) {
|
|
return error.bufferedData;
|
|
}
|
|
};
|
|
|
|
const getStreamPromise = (stream, {encoding, buffer, maxBuffer}) => {
|
|
if (!stream || !buffer) {
|
|
return;
|
|
}
|
|
|
|
if (encoding) {
|
|
return getStream(stream, {encoding, maxBuffer});
|
|
}
|
|
|
|
return getStream.buffer(stream, {maxBuffer});
|
|
};
|
|
|
|
// Retrieve result of child process: exit code, signal, error, streams (stdout/stderr/all)
|
|
const getSpawnedResult$1 = async ({stdout, stderr, all}, {encoding, buffer, maxBuffer}, processDone) => {
|
|
const stdoutPromise = getStreamPromise(stdout, {encoding, buffer, maxBuffer});
|
|
const stderrPromise = getStreamPromise(stderr, {encoding, buffer, maxBuffer});
|
|
const allPromise = getStreamPromise(all, {encoding, buffer, maxBuffer: maxBuffer * 2});
|
|
|
|
try {
|
|
return await Promise.all([processDone, stdoutPromise, stderrPromise, allPromise]);
|
|
} catch (error) {
|
|
return Promise.all([
|
|
{error, signal: error.signal, timedOut: error.timedOut},
|
|
getBufferedData(stdout, stdoutPromise),
|
|
getBufferedData(stderr, stderrPromise),
|
|
getBufferedData(all, allPromise)
|
|
]);
|
|
}
|
|
};
|
|
|
|
const validateInputSync$1 = ({input}) => {
|
|
if (isStream(input)) {
|
|
throw new TypeError('The `input` option cannot be a stream in sync mode');
|
|
}
|
|
};
|
|
|
|
var stream = {
|
|
handleInput: handleInput$1,
|
|
makeAllStream: makeAllStream$1,
|
|
getSpawnedResult: getSpawnedResult$1,
|
|
validateInputSync: validateInputSync$1
|
|
};
|
|
|
|
const nativePromisePrototype = (async () => {})().constructor.prototype;
|
|
const descriptors = ['then', 'catch', 'finally'].map(property => [
|
|
property,
|
|
Reflect.getOwnPropertyDescriptor(nativePromisePrototype, property)
|
|
]);
|
|
|
|
// The return value is a mixin of `childProcess` and `Promise`
|
|
const mergePromise$1 = (spawned, promise) => {
|
|
for (const [property, descriptor] of descriptors) {
|
|
// Starting the main `promise` is deferred to avoid consuming streams
|
|
const value = typeof promise === 'function' ?
|
|
(...args) => Reflect.apply(descriptor.value, promise(), args) :
|
|
descriptor.value.bind(promise);
|
|
|
|
Reflect.defineProperty(spawned, property, {...descriptor, value});
|
|
}
|
|
|
|
return spawned;
|
|
};
|
|
|
|
// Use promises instead of `child_process` events
|
|
const getSpawnedPromise$1 = spawned => {
|
|
return new Promise((resolve, reject) => {
|
|
spawned.on('exit', (exitCode, signal) => {
|
|
resolve({exitCode, signal});
|
|
});
|
|
|
|
spawned.on('error', error => {
|
|
reject(error);
|
|
});
|
|
|
|
if (spawned.stdin) {
|
|
spawned.stdin.on('error', error => {
|
|
reject(error);
|
|
});
|
|
}
|
|
});
|
|
};
|
|
|
|
var promise = {
|
|
mergePromise: mergePromise$1,
|
|
getSpawnedPromise: getSpawnedPromise$1
|
|
};
|
|
|
|
const normalizeArgs = (file, args = []) => {
|
|
if (!Array.isArray(args)) {
|
|
return [file];
|
|
}
|
|
|
|
return [file, ...args];
|
|
};
|
|
|
|
const NO_ESCAPE_REGEXP = /^[\w.-]+$/;
|
|
const DOUBLE_QUOTES_REGEXP = /"/g;
|
|
|
|
const escapeArg = arg => {
|
|
if (typeof arg !== 'string' || NO_ESCAPE_REGEXP.test(arg)) {
|
|
return arg;
|
|
}
|
|
|
|
return `"${arg.replace(DOUBLE_QUOTES_REGEXP, '\\"')}"`;
|
|
};
|
|
|
|
const joinCommand$1 = (file, args) => {
|
|
return normalizeArgs(file, args).join(' ');
|
|
};
|
|
|
|
const getEscapedCommand$1 = (file, args) => {
|
|
return normalizeArgs(file, args).map(arg => escapeArg(arg)).join(' ');
|
|
};
|
|
|
|
const SPACES_REGEXP = / +/g;
|
|
|
|
// Handle `execa.command()`
|
|
const parseCommand$1 = command => {
|
|
const tokens = [];
|
|
for (const token of command.trim().split(SPACES_REGEXP)) {
|
|
// Allow spaces to be escaped by a backslash if not meant as a delimiter
|
|
const previousToken = tokens[tokens.length - 1];
|
|
if (previousToken && previousToken.endsWith('\\')) {
|
|
// Merge previous token with current one
|
|
tokens[tokens.length - 1] = `${previousToken.slice(0, -1)} ${token}`;
|
|
} else {
|
|
tokens.push(token);
|
|
}
|
|
}
|
|
|
|
return tokens;
|
|
};
|
|
|
|
var command = {
|
|
joinCommand: joinCommand$1,
|
|
getEscapedCommand: getEscapedCommand$1,
|
|
parseCommand: parseCommand$1
|
|
};
|
|
|
|
const path = g;
|
|
const childProcess = require$$0$2;
|
|
const crossSpawn = crossSpawn$1.exports;
|
|
const stripFinalNewline = stripFinalNewline$1;
|
|
const npmRunPath = npmRunPath$1.exports;
|
|
const onetime = onetime$1.exports;
|
|
const makeError = error;
|
|
const normalizeStdio = stdio.exports;
|
|
const {spawnedKill, spawnedCancel, setupTimeout, validateTimeout, setExitHandler} = kill;
|
|
const {handleInput, getSpawnedResult, makeAllStream, validateInputSync} = stream;
|
|
const {mergePromise, getSpawnedPromise} = promise;
|
|
const {joinCommand, parseCommand, getEscapedCommand} = command;
|
|
|
|
const DEFAULT_MAX_BUFFER = 1000 * 1000 * 100;
|
|
|
|
const getEnv = ({env: envOption, extendEnv, preferLocal, localDir, execPath}) => {
|
|
const env = extendEnv ? {...process.env, ...envOption} : envOption;
|
|
|
|
if (preferLocal) {
|
|
return npmRunPath.env({env, cwd: localDir, execPath});
|
|
}
|
|
|
|
return env;
|
|
};
|
|
|
|
const handleArguments = (file, args, options = {}) => {
|
|
const parsed = crossSpawn._parse(file, args, options);
|
|
file = parsed.command;
|
|
args = parsed.args;
|
|
options = parsed.options;
|
|
|
|
options = {
|
|
maxBuffer: DEFAULT_MAX_BUFFER,
|
|
buffer: true,
|
|
stripFinalNewline: true,
|
|
extendEnv: true,
|
|
preferLocal: false,
|
|
localDir: options.cwd || process.cwd(),
|
|
execPath: process.execPath,
|
|
encoding: 'utf8',
|
|
reject: true,
|
|
cleanup: true,
|
|
all: false,
|
|
windowsHide: true,
|
|
...options
|
|
};
|
|
|
|
options.env = getEnv(options);
|
|
|
|
options.stdio = normalizeStdio(options);
|
|
|
|
if (process.platform === 'win32' && path.basename(file, '.exe') === 'cmd') {
|
|
// #116
|
|
args.unshift('/q');
|
|
}
|
|
|
|
return {file, args, options, parsed};
|
|
};
|
|
|
|
const handleOutput = (options, value, error) => {
|
|
if (typeof value !== 'string' && !Buffer.isBuffer(value)) {
|
|
// When `execa.sync()` errors, we normalize it to '' to mimic `execa()`
|
|
return error === undefined ? undefined : '';
|
|
}
|
|
|
|
if (options.stripFinalNewline) {
|
|
return stripFinalNewline(value);
|
|
}
|
|
|
|
return value;
|
|
};
|
|
|
|
const execa = (file, args, options) => {
|
|
const parsed = handleArguments(file, args, options);
|
|
const command = joinCommand(file, args);
|
|
const escapedCommand = getEscapedCommand(file, args);
|
|
|
|
validateTimeout(parsed.options);
|
|
|
|
let spawned;
|
|
try {
|
|
spawned = childProcess.spawn(parsed.file, parsed.args, parsed.options);
|
|
} catch (error) {
|
|
// Ensure the returned error is always both a promise and a child process
|
|
const dummySpawned = new childProcess.ChildProcess();
|
|
const errorPromise = Promise.reject(makeError({
|
|
error,
|
|
stdout: '',
|
|
stderr: '',
|
|
all: '',
|
|
command,
|
|
escapedCommand,
|
|
parsed,
|
|
timedOut: false,
|
|
isCanceled: false,
|
|
killed: false
|
|
}));
|
|
return mergePromise(dummySpawned, errorPromise);
|
|
}
|
|
|
|
const spawnedPromise = getSpawnedPromise(spawned);
|
|
const timedPromise = setupTimeout(spawned, parsed.options, spawnedPromise);
|
|
const processDone = setExitHandler(spawned, parsed.options, timedPromise);
|
|
|
|
const context = {isCanceled: false};
|
|
|
|
spawned.kill = spawnedKill.bind(null, spawned.kill.bind(spawned));
|
|
spawned.cancel = spawnedCancel.bind(null, spawned, context);
|
|
|
|
const handlePromise = async () => {
|
|
const [{error, exitCode, signal, timedOut}, stdoutResult, stderrResult, allResult] = await getSpawnedResult(spawned, parsed.options, processDone);
|
|
const stdout = handleOutput(parsed.options, stdoutResult);
|
|
const stderr = handleOutput(parsed.options, stderrResult);
|
|
const all = handleOutput(parsed.options, allResult);
|
|
|
|
if (error || exitCode !== 0 || signal !== null) {
|
|
const returnedError = makeError({
|
|
error,
|
|
exitCode,
|
|
signal,
|
|
stdout,
|
|
stderr,
|
|
all,
|
|
command,
|
|
escapedCommand,
|
|
parsed,
|
|
timedOut,
|
|
isCanceled: context.isCanceled,
|
|
killed: spawned.killed
|
|
});
|
|
|
|
if (!parsed.options.reject) {
|
|
return returnedError;
|
|
}
|
|
|
|
throw returnedError;
|
|
}
|
|
|
|
return {
|
|
command,
|
|
escapedCommand,
|
|
exitCode: 0,
|
|
stdout,
|
|
stderr,
|
|
all,
|
|
failed: false,
|
|
timedOut: false,
|
|
isCanceled: false,
|
|
killed: false
|
|
};
|
|
};
|
|
|
|
const handlePromiseOnce = onetime(handlePromise);
|
|
|
|
handleInput(spawned, parsed.options.input);
|
|
|
|
spawned.all = makeAllStream(spawned, parsed.options);
|
|
|
|
return mergePromise(spawned, handlePromiseOnce);
|
|
};
|
|
|
|
execa$1.exports = execa;
|
|
|
|
execa$1.exports.sync = (file, args, options) => {
|
|
const parsed = handleArguments(file, args, options);
|
|
const command = joinCommand(file, args);
|
|
const escapedCommand = getEscapedCommand(file, args);
|
|
|
|
validateInputSync(parsed.options);
|
|
|
|
let result;
|
|
try {
|
|
result = childProcess.spawnSync(parsed.file, parsed.args, parsed.options);
|
|
} catch (error) {
|
|
throw makeError({
|
|
error,
|
|
stdout: '',
|
|
stderr: '',
|
|
all: '',
|
|
command,
|
|
escapedCommand,
|
|
parsed,
|
|
timedOut: false,
|
|
isCanceled: false,
|
|
killed: false
|
|
});
|
|
}
|
|
|
|
const stdout = handleOutput(parsed.options, result.stdout, result.error);
|
|
const stderr = handleOutput(parsed.options, result.stderr, result.error);
|
|
|
|
if (result.error || result.status !== 0 || result.signal !== null) {
|
|
const error = makeError({
|
|
stdout,
|
|
stderr,
|
|
error: result.error,
|
|
signal: result.signal,
|
|
exitCode: result.status,
|
|
command,
|
|
escapedCommand,
|
|
parsed,
|
|
timedOut: result.error && result.error.code === 'ETIMEDOUT',
|
|
isCanceled: false,
|
|
killed: result.signal !== null
|
|
});
|
|
|
|
if (!parsed.options.reject) {
|
|
return error;
|
|
}
|
|
|
|
throw error;
|
|
}
|
|
|
|
return {
|
|
command,
|
|
escapedCommand,
|
|
exitCode: 0,
|
|
stdout,
|
|
stderr,
|
|
failed: false,
|
|
timedOut: false,
|
|
isCanceled: false,
|
|
killed: false
|
|
};
|
|
};
|
|
|
|
execa$1.exports.command = (command, options) => {
|
|
const [file, ...args] = parseCommand(command);
|
|
return execa(file, args, options);
|
|
};
|
|
|
|
execa$1.exports.commandSync = (command, options) => {
|
|
const [file, ...args] = parseCommand(command);
|
|
return execa.sync(file, args, options);
|
|
};
|
|
|
|
execa$1.exports.node = (scriptPath, args, options = {}) => {
|
|
if (args && !Array.isArray(args) && typeof args === 'object') {
|
|
options = args;
|
|
args = [];
|
|
}
|
|
|
|
const stdio = normalizeStdio.node(options);
|
|
const defaultExecArgv = process.execArgv.filter(arg => !arg.startsWith('--inspect'));
|
|
|
|
const {
|
|
nodePath = process.execPath,
|
|
nodeOptions = defaultExecArgv
|
|
} = options;
|
|
|
|
return execa(
|
|
nodePath,
|
|
[
|
|
...nodeOptions,
|
|
scriptPath,
|
|
...(Array.isArray(args) ? args : [])
|
|
],
|
|
{
|
|
...options,
|
|
stdin: undefined,
|
|
stdout: undefined,
|
|
stderr: undefined,
|
|
stdio,
|
|
shell: false
|
|
}
|
|
);
|
|
};
|
|
|
|
// src/detect.ts
|
|
var AGENTS = ["pnpm", "yarn", "npm", "pnpm@6", "yarn@berry", "bun"];
|
|
var LOCKS = {
|
|
"bun.lockb": "bun",
|
|
"pnpm-lock.yaml": "pnpm",
|
|
"yarn.lock": "yarn",
|
|
"package-lock.json": "npm",
|
|
"npm-shrinkwrap.json": "npm"
|
|
};
|
|
async function detectPackageManager(cwd = process.cwd()) {
|
|
let agent = null;
|
|
const lockPath = await findUp(Object.keys(LOCKS), { cwd });
|
|
let packageJsonPath;
|
|
if (lockPath)
|
|
packageJsonPath = g.resolve(lockPath, "../package.json");
|
|
else
|
|
packageJsonPath = await findUp("package.json", { cwd });
|
|
if (packageJsonPath && require$$0.existsSync(packageJsonPath)) {
|
|
try {
|
|
const pkg = JSON.parse(require$$0.readFileSync(packageJsonPath, "utf8"));
|
|
if (typeof pkg.packageManager === "string") {
|
|
const [name, version] = pkg.packageManager.split("@");
|
|
if (name === "yarn" && parseInt(version) > 1)
|
|
agent = "yarn@berry";
|
|
else if (name === "pnpm" && parseInt(version) < 7)
|
|
agent = "pnpm@6";
|
|
else if (name in AGENTS)
|
|
agent = name;
|
|
else
|
|
console.warn("[ni] Unknown packageManager:", pkg.packageManager);
|
|
}
|
|
} catch {
|
|
}
|
|
}
|
|
if (!agent && lockPath)
|
|
agent = LOCKS[g.basename(lockPath)];
|
|
return agent;
|
|
}
|
|
async function installPackage(names, options = {}) {
|
|
const detectedAgent = options.packageManager || await detectPackageManager(options.cwd) || "npm";
|
|
const [agent] = detectedAgent.split("@");
|
|
if (!Array.isArray(names))
|
|
names = [names];
|
|
const args = options.additionalArgs || [];
|
|
if (options.preferOffline) {
|
|
if (detectedAgent === "yarn@berry")
|
|
args.unshift("--cached");
|
|
else
|
|
args.unshift("--prefer-offline");
|
|
}
|
|
return execa$1.exports(
|
|
agent,
|
|
[
|
|
agent === "yarn" ? "add" : "install",
|
|
options.dev ? "-D" : "",
|
|
...args,
|
|
...names
|
|
].filter(Boolean),
|
|
{
|
|
stdio: options.silent ? "ignore" : "inherit",
|
|
cwd: options.cwd
|
|
}
|
|
);
|
|
}
|
|
|
|
export { detectPackageManager, installPackage };
|
|
|