chunk-install-pkg.3aa3eae6.mjs 35 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642
  1. import path$2 from 'path';
  2. import fs$2 from 'fs';
  3. import util from 'util';
  4. import childProcess$1 from 'child_process';
  5. import { p as pathKey, m as mergeStream$1, g as getStream$1, c as crossSpawn$1 } from './vendor-index.2ae8040a.mjs';
  6. import { o as onetime$1 } from './vendor-index.9d9196cc.mjs';
  7. import require$$0 from 'os';
  8. import { s as signalExit } from './vendor-index.29636037.mjs';
  9. import './vendor-_commonjsHelpers.4da45ef5.mjs';
  10. import 'buffer';
  11. import 'stream';
  12. import 'assert';
  13. import 'events';
  14. var findUp$1 = {exports: {}};
  15. var locatePath = {exports: {}};
  16. class Node {
  17. /// value;
  18. /// next;
  19. constructor(value) {
  20. this.value = value;
  21. // TODO: Remove this when targeting Node.js 12.
  22. this.next = undefined;
  23. }
  24. }
  25. class Queue$1 {
  26. // TODO: Use private class fields when targeting Node.js 12.
  27. // #_head;
  28. // #_tail;
  29. // #_size;
  30. constructor() {
  31. this.clear();
  32. }
  33. enqueue(value) {
  34. const node = new Node(value);
  35. if (this._head) {
  36. this._tail.next = node;
  37. this._tail = node;
  38. } else {
  39. this._head = node;
  40. this._tail = node;
  41. }
  42. this._size++;
  43. }
  44. dequeue() {
  45. const current = this._head;
  46. if (!current) {
  47. return;
  48. }
  49. this._head = this._head.next;
  50. this._size--;
  51. return current.value;
  52. }
  53. clear() {
  54. this._head = undefined;
  55. this._tail = undefined;
  56. this._size = 0;
  57. }
  58. get size() {
  59. return this._size;
  60. }
  61. * [Symbol.iterator]() {
  62. let current = this._head;
  63. while (current) {
  64. yield current.value;
  65. current = current.next;
  66. }
  67. }
  68. }
  69. var yoctoQueue = Queue$1;
  70. const Queue = yoctoQueue;
  71. const pLimit$1 = concurrency => {
  72. if (!((Number.isInteger(concurrency) || concurrency === Infinity) && concurrency > 0)) {
  73. throw new TypeError('Expected `concurrency` to be a number from 1 and up');
  74. }
  75. const queue = new Queue();
  76. let activeCount = 0;
  77. const next = () => {
  78. activeCount--;
  79. if (queue.size > 0) {
  80. queue.dequeue()();
  81. }
  82. };
  83. const run = async (fn, resolve, ...args) => {
  84. activeCount++;
  85. const result = (async () => fn(...args))();
  86. resolve(result);
  87. try {
  88. await result;
  89. } catch {}
  90. next();
  91. };
  92. const enqueue = (fn, resolve, ...args) => {
  93. queue.enqueue(run.bind(null, fn, resolve, ...args));
  94. (async () => {
  95. // This function needs to wait until the next microtask before comparing
  96. // `activeCount` to `concurrency`, because `activeCount` is updated asynchronously
  97. // when the run function is dequeued and called. The comparison in the if-statement
  98. // needs to happen asynchronously as well to get an up-to-date value for `activeCount`.
  99. await Promise.resolve();
  100. if (activeCount < concurrency && queue.size > 0) {
  101. queue.dequeue()();
  102. }
  103. })();
  104. };
  105. const generator = (fn, ...args) => new Promise(resolve => {
  106. enqueue(fn, resolve, ...args);
  107. });
  108. Object.defineProperties(generator, {
  109. activeCount: {
  110. get: () => activeCount
  111. },
  112. pendingCount: {
  113. get: () => queue.size
  114. },
  115. clearQueue: {
  116. value: () => {
  117. queue.clear();
  118. }
  119. }
  120. });
  121. return generator;
  122. };
  123. var pLimit_1 = pLimit$1;
  124. const pLimit = pLimit_1;
  125. class EndError extends Error {
  126. constructor(value) {
  127. super();
  128. this.value = value;
  129. }
  130. }
  131. // The input can also be a promise, so we await it
  132. const testElement = async (element, tester) => tester(await element);
  133. // The input can also be a promise, so we `Promise.all()` them both
  134. const finder = async element => {
  135. const values = await Promise.all(element);
  136. if (values[1] === true) {
  137. throw new EndError(values[0]);
  138. }
  139. return false;
  140. };
  141. const pLocate$1 = async (iterable, tester, options) => {
  142. options = {
  143. concurrency: Infinity,
  144. preserveOrder: true,
  145. ...options
  146. };
  147. const limit = pLimit(options.concurrency);
  148. // Start all the promises concurrently with optional limit
  149. const items = [...iterable].map(element => [element, limit(testElement, element, tester)]);
  150. // Check the promises either serially or concurrently
  151. const checkLimit = pLimit(options.preserveOrder ? 1 : Infinity);
  152. try {
  153. await Promise.all(items.map(element => checkLimit(finder, element)));
  154. } catch (error) {
  155. if (error instanceof EndError) {
  156. return error.value;
  157. }
  158. throw error;
  159. }
  160. };
  161. var pLocate_1 = pLocate$1;
  162. const path$1 = path$2;
  163. const fs$1 = fs$2;
  164. const {promisify: promisify$1} = util;
  165. const pLocate = pLocate_1;
  166. const fsStat = promisify$1(fs$1.stat);
  167. const fsLStat = promisify$1(fs$1.lstat);
  168. const typeMappings = {
  169. directory: 'isDirectory',
  170. file: 'isFile'
  171. };
  172. function checkType({type}) {
  173. if (type in typeMappings) {
  174. return;
  175. }
  176. throw new Error(`Invalid type specified: ${type}`);
  177. }
  178. const matchType = (type, stat) => type === undefined || stat[typeMappings[type]]();
  179. locatePath.exports = async (paths, options) => {
  180. options = {
  181. cwd: process.cwd(),
  182. type: 'file',
  183. allowSymlinks: true,
  184. ...options
  185. };
  186. checkType(options);
  187. const statFn = options.allowSymlinks ? fsStat : fsLStat;
  188. return pLocate(paths, async path_ => {
  189. try {
  190. const stat = await statFn(path$1.resolve(options.cwd, path_));
  191. return matchType(options.type, stat);
  192. } catch {
  193. return false;
  194. }
  195. }, options);
  196. };
  197. locatePath.exports.sync = (paths, options) => {
  198. options = {
  199. cwd: process.cwd(),
  200. allowSymlinks: true,
  201. type: 'file',
  202. ...options
  203. };
  204. checkType(options);
  205. const statFn = options.allowSymlinks ? fs$1.statSync : fs$1.lstatSync;
  206. for (const path_ of paths) {
  207. try {
  208. const stat = statFn(path$1.resolve(options.cwd, path_));
  209. if (matchType(options.type, stat)) {
  210. return path_;
  211. }
  212. } catch {}
  213. }
  214. };
  215. var pathExists = {exports: {}};
  216. const fs = fs$2;
  217. const {promisify} = util;
  218. const pAccess = promisify(fs.access);
  219. pathExists.exports = async path => {
  220. try {
  221. await pAccess(path);
  222. return true;
  223. } catch (_) {
  224. return false;
  225. }
  226. };
  227. pathExists.exports.sync = path => {
  228. try {
  229. fs.accessSync(path);
  230. return true;
  231. } catch (_) {
  232. return false;
  233. }
  234. };
  235. (function (module) {
  236. const path = path$2;
  237. const locatePath$1 = locatePath.exports;
  238. const pathExists$1 = pathExists.exports;
  239. const stop = Symbol('findUp.stop');
  240. module.exports = async (name, options = {}) => {
  241. let directory = path.resolve(options.cwd || '');
  242. const {root} = path.parse(directory);
  243. const paths = [].concat(name);
  244. const runMatcher = async locateOptions => {
  245. if (typeof name !== 'function') {
  246. return locatePath$1(paths, locateOptions);
  247. }
  248. const foundPath = await name(locateOptions.cwd);
  249. if (typeof foundPath === 'string') {
  250. return locatePath$1([foundPath], locateOptions);
  251. }
  252. return foundPath;
  253. };
  254. // eslint-disable-next-line no-constant-condition
  255. while (true) {
  256. // eslint-disable-next-line no-await-in-loop
  257. const foundPath = await runMatcher({...options, cwd: directory});
  258. if (foundPath === stop) {
  259. return;
  260. }
  261. if (foundPath) {
  262. return path.resolve(directory, foundPath);
  263. }
  264. if (directory === root) {
  265. return;
  266. }
  267. directory = path.dirname(directory);
  268. }
  269. };
  270. module.exports.sync = (name, options = {}) => {
  271. let directory = path.resolve(options.cwd || '');
  272. const {root} = path.parse(directory);
  273. const paths = [].concat(name);
  274. const runMatcher = locateOptions => {
  275. if (typeof name !== 'function') {
  276. return locatePath$1.sync(paths, locateOptions);
  277. }
  278. const foundPath = name(locateOptions.cwd);
  279. if (typeof foundPath === 'string') {
  280. return locatePath$1.sync([foundPath], locateOptions);
  281. }
  282. return foundPath;
  283. };
  284. // eslint-disable-next-line no-constant-condition
  285. while (true) {
  286. const foundPath = runMatcher({...options, cwd: directory});
  287. if (foundPath === stop) {
  288. return;
  289. }
  290. if (foundPath) {
  291. return path.resolve(directory, foundPath);
  292. }
  293. if (directory === root) {
  294. return;
  295. }
  296. directory = path.dirname(directory);
  297. }
  298. };
  299. module.exports.exists = pathExists$1;
  300. module.exports.sync.exists = pathExists$1.sync;
  301. module.exports.stop = stop;
  302. } (findUp$1));
  303. var findUp = findUp$1.exports;
  304. var execa$1 = {exports: {}};
  305. var stripFinalNewline$1 = input => {
  306. const LF = typeof input === 'string' ? '\n' : '\n'.charCodeAt();
  307. const CR = typeof input === 'string' ? '\r' : '\r'.charCodeAt();
  308. if (input[input.length - 1] === LF) {
  309. input = input.slice(0, input.length - 1);
  310. }
  311. if (input[input.length - 1] === CR) {
  312. input = input.slice(0, input.length - 1);
  313. }
  314. return input;
  315. };
  316. var npmRunPath$1 = {exports: {}};
  317. (function (module) {
  318. const path = path$2;
  319. const pathKey$1 = pathKey.exports;
  320. const npmRunPath = options => {
  321. options = {
  322. cwd: process.cwd(),
  323. path: process.env[pathKey$1()],
  324. execPath: process.execPath,
  325. ...options
  326. };
  327. let previous;
  328. let cwdPath = path.resolve(options.cwd);
  329. const result = [];
  330. while (previous !== cwdPath) {
  331. result.push(path.join(cwdPath, 'node_modules/.bin'));
  332. previous = cwdPath;
  333. cwdPath = path.resolve(cwdPath, '..');
  334. }
  335. // Ensure the running `node` binary is used
  336. const execPathDir = path.resolve(options.cwd, options.execPath, '..');
  337. result.push(execPathDir);
  338. return result.concat(options.path).join(path.delimiter);
  339. };
  340. module.exports = npmRunPath;
  341. // TODO: Remove this for the next major release
  342. module.exports.default = npmRunPath;
  343. module.exports.env = options => {
  344. options = {
  345. env: process.env,
  346. ...options
  347. };
  348. const env = {...options.env};
  349. const path = pathKey$1({env});
  350. options.path = env[path];
  351. env[path] = module.exports(options);
  352. return env;
  353. };
  354. } (npmRunPath$1));
  355. var main = {};
  356. var signals = {};
  357. var core = {};
  358. Object.defineProperty(core,"__esModule",{value:true});core.SIGNALS=void 0;
  359. const SIGNALS=[
  360. {
  361. name:"SIGHUP",
  362. number:1,
  363. action:"terminate",
  364. description:"Terminal closed",
  365. standard:"posix"},
  366. {
  367. name:"SIGINT",
  368. number:2,
  369. action:"terminate",
  370. description:"User interruption with CTRL-C",
  371. standard:"ansi"},
  372. {
  373. name:"SIGQUIT",
  374. number:3,
  375. action:"core",
  376. description:"User interruption with CTRL-\\",
  377. standard:"posix"},
  378. {
  379. name:"SIGILL",
  380. number:4,
  381. action:"core",
  382. description:"Invalid machine instruction",
  383. standard:"ansi"},
  384. {
  385. name:"SIGTRAP",
  386. number:5,
  387. action:"core",
  388. description:"Debugger breakpoint",
  389. standard:"posix"},
  390. {
  391. name:"SIGABRT",
  392. number:6,
  393. action:"core",
  394. description:"Aborted",
  395. standard:"ansi"},
  396. {
  397. name:"SIGIOT",
  398. number:6,
  399. action:"core",
  400. description:"Aborted",
  401. standard:"bsd"},
  402. {
  403. name:"SIGBUS",
  404. number:7,
  405. action:"core",
  406. description:
  407. "Bus error due to misaligned, non-existing address or paging error",
  408. standard:"bsd"},
  409. {
  410. name:"SIGEMT",
  411. number:7,
  412. action:"terminate",
  413. description:"Command should be emulated but is not implemented",
  414. standard:"other"},
  415. {
  416. name:"SIGFPE",
  417. number:8,
  418. action:"core",
  419. description:"Floating point arithmetic error",
  420. standard:"ansi"},
  421. {
  422. name:"SIGKILL",
  423. number:9,
  424. action:"terminate",
  425. description:"Forced termination",
  426. standard:"posix",
  427. forced:true},
  428. {
  429. name:"SIGUSR1",
  430. number:10,
  431. action:"terminate",
  432. description:"Application-specific signal",
  433. standard:"posix"},
  434. {
  435. name:"SIGSEGV",
  436. number:11,
  437. action:"core",
  438. description:"Segmentation fault",
  439. standard:"ansi"},
  440. {
  441. name:"SIGUSR2",
  442. number:12,
  443. action:"terminate",
  444. description:"Application-specific signal",
  445. standard:"posix"},
  446. {
  447. name:"SIGPIPE",
  448. number:13,
  449. action:"terminate",
  450. description:"Broken pipe or socket",
  451. standard:"posix"},
  452. {
  453. name:"SIGALRM",
  454. number:14,
  455. action:"terminate",
  456. description:"Timeout or timer",
  457. standard:"posix"},
  458. {
  459. name:"SIGTERM",
  460. number:15,
  461. action:"terminate",
  462. description:"Termination",
  463. standard:"ansi"},
  464. {
  465. name:"SIGSTKFLT",
  466. number:16,
  467. action:"terminate",
  468. description:"Stack is empty or overflowed",
  469. standard:"other"},
  470. {
  471. name:"SIGCHLD",
  472. number:17,
  473. action:"ignore",
  474. description:"Child process terminated, paused or unpaused",
  475. standard:"posix"},
  476. {
  477. name:"SIGCLD",
  478. number:17,
  479. action:"ignore",
  480. description:"Child process terminated, paused or unpaused",
  481. standard:"other"},
  482. {
  483. name:"SIGCONT",
  484. number:18,
  485. action:"unpause",
  486. description:"Unpaused",
  487. standard:"posix",
  488. forced:true},
  489. {
  490. name:"SIGSTOP",
  491. number:19,
  492. action:"pause",
  493. description:"Paused",
  494. standard:"posix",
  495. forced:true},
  496. {
  497. name:"SIGTSTP",
  498. number:20,
  499. action:"pause",
  500. description:"Paused using CTRL-Z or \"suspend\"",
  501. standard:"posix"},
  502. {
  503. name:"SIGTTIN",
  504. number:21,
  505. action:"pause",
  506. description:"Background process cannot read terminal input",
  507. standard:"posix"},
  508. {
  509. name:"SIGBREAK",
  510. number:21,
  511. action:"terminate",
  512. description:"User interruption with CTRL-BREAK",
  513. standard:"other"},
  514. {
  515. name:"SIGTTOU",
  516. number:22,
  517. action:"pause",
  518. description:"Background process cannot write to terminal output",
  519. standard:"posix"},
  520. {
  521. name:"SIGURG",
  522. number:23,
  523. action:"ignore",
  524. description:"Socket received out-of-band data",
  525. standard:"bsd"},
  526. {
  527. name:"SIGXCPU",
  528. number:24,
  529. action:"core",
  530. description:"Process timed out",
  531. standard:"bsd"},
  532. {
  533. name:"SIGXFSZ",
  534. number:25,
  535. action:"core",
  536. description:"File too big",
  537. standard:"bsd"},
  538. {
  539. name:"SIGVTALRM",
  540. number:26,
  541. action:"terminate",
  542. description:"Timeout or timer",
  543. standard:"bsd"},
  544. {
  545. name:"SIGPROF",
  546. number:27,
  547. action:"terminate",
  548. description:"Timeout or timer",
  549. standard:"bsd"},
  550. {
  551. name:"SIGWINCH",
  552. number:28,
  553. action:"ignore",
  554. description:"Terminal window size changed",
  555. standard:"bsd"},
  556. {
  557. name:"SIGIO",
  558. number:29,
  559. action:"terminate",
  560. description:"I/O is available",
  561. standard:"other"},
  562. {
  563. name:"SIGPOLL",
  564. number:29,
  565. action:"terminate",
  566. description:"Watched event",
  567. standard:"other"},
  568. {
  569. name:"SIGINFO",
  570. number:29,
  571. action:"ignore",
  572. description:"Request for process information",
  573. standard:"other"},
  574. {
  575. name:"SIGPWR",
  576. number:30,
  577. action:"terminate",
  578. description:"Device running out of power",
  579. standard:"systemv"},
  580. {
  581. name:"SIGSYS",
  582. number:31,
  583. action:"core",
  584. description:"Invalid system call",
  585. standard:"other"},
  586. {
  587. name:"SIGUNUSED",
  588. number:31,
  589. action:"terminate",
  590. description:"Invalid system call",
  591. standard:"other"}];core.SIGNALS=SIGNALS;
  592. var realtime = {};
  593. Object.defineProperty(realtime,"__esModule",{value:true});realtime.SIGRTMAX=realtime.getRealtimeSignals=void 0;
  594. const getRealtimeSignals=function(){
  595. const length=SIGRTMAX-SIGRTMIN+1;
  596. return Array.from({length},getRealtimeSignal);
  597. };realtime.getRealtimeSignals=getRealtimeSignals;
  598. const getRealtimeSignal=function(value,index){
  599. return {
  600. name:`SIGRT${index+1}`,
  601. number:SIGRTMIN+index,
  602. action:"terminate",
  603. description:"Application-specific signal (realtime)",
  604. standard:"posix"};
  605. };
  606. const SIGRTMIN=34;
  607. const SIGRTMAX=64;realtime.SIGRTMAX=SIGRTMAX;
  608. Object.defineProperty(signals,"__esModule",{value:true});signals.getSignals=void 0;var _os$1=require$$0;
  609. var _core=core;
  610. var _realtime$1=realtime;
  611. const getSignals=function(){
  612. const realtimeSignals=(0, _realtime$1.getRealtimeSignals)();
  613. const signals=[..._core.SIGNALS,...realtimeSignals].map(normalizeSignal);
  614. return signals;
  615. };signals.getSignals=getSignals;
  616. const normalizeSignal=function({
  617. name,
  618. number:defaultNumber,
  619. description,
  620. action,
  621. forced=false,
  622. standard})
  623. {
  624. const{
  625. signals:{[name]:constantSignal}}=
  626. _os$1.constants;
  627. const supported=constantSignal!==undefined;
  628. const number=supported?constantSignal:defaultNumber;
  629. return {name,number,description,supported,action,forced,standard};
  630. };
  631. Object.defineProperty(main,"__esModule",{value:true});main.signalsByNumber=main.signalsByName=void 0;var _os=require$$0;
  632. var _signals=signals;
  633. var _realtime=realtime;
  634. const getSignalsByName=function(){
  635. const signals=(0, _signals.getSignals)();
  636. return signals.reduce(getSignalByName,{});
  637. };
  638. const getSignalByName=function(
  639. signalByNameMemo,
  640. {name,number,description,supported,action,forced,standard})
  641. {
  642. return {
  643. ...signalByNameMemo,
  644. [name]:{name,number,description,supported,action,forced,standard}};
  645. };
  646. const signalsByName$1=getSignalsByName();main.signalsByName=signalsByName$1;
  647. const getSignalsByNumber=function(){
  648. const signals=(0, _signals.getSignals)();
  649. const length=_realtime.SIGRTMAX+1;
  650. const signalsA=Array.from({length},(value,number)=>
  651. getSignalByNumber(number,signals));
  652. return Object.assign({},...signalsA);
  653. };
  654. const getSignalByNumber=function(number,signals){
  655. const signal=findSignalByNumber(number,signals);
  656. if(signal===undefined){
  657. return {};
  658. }
  659. const{name,description,supported,action,forced,standard}=signal;
  660. return {
  661. [number]:{
  662. name,
  663. number,
  664. description,
  665. supported,
  666. action,
  667. forced,
  668. standard}};
  669. };
  670. const findSignalByNumber=function(number,signals){
  671. const signal=signals.find(({name})=>_os.constants.signals[name]===number);
  672. if(signal!==undefined){
  673. return signal;
  674. }
  675. return signals.find(signalA=>signalA.number===number);
  676. };
  677. const signalsByNumber=getSignalsByNumber();main.signalsByNumber=signalsByNumber;
  678. const {signalsByName} = main;
  679. const getErrorPrefix = ({timedOut, timeout, errorCode, signal, signalDescription, exitCode, isCanceled}) => {
  680. if (timedOut) {
  681. return `timed out after ${timeout} milliseconds`;
  682. }
  683. if (isCanceled) {
  684. return 'was canceled';
  685. }
  686. if (errorCode !== undefined) {
  687. return `failed with ${errorCode}`;
  688. }
  689. if (signal !== undefined) {
  690. return `was killed with ${signal} (${signalDescription})`;
  691. }
  692. if (exitCode !== undefined) {
  693. return `failed with exit code ${exitCode}`;
  694. }
  695. return 'failed';
  696. };
  697. const makeError$1 = ({
  698. stdout,
  699. stderr,
  700. all,
  701. error,
  702. signal,
  703. exitCode,
  704. command,
  705. escapedCommand,
  706. timedOut,
  707. isCanceled,
  708. killed,
  709. parsed: {options: {timeout}}
  710. }) => {
  711. // `signal` and `exitCode` emitted on `spawned.on('exit')` event can be `null`.
  712. // We normalize them to `undefined`
  713. exitCode = exitCode === null ? undefined : exitCode;
  714. signal = signal === null ? undefined : signal;
  715. const signalDescription = signal === undefined ? undefined : signalsByName[signal].description;
  716. const errorCode = error && error.code;
  717. const prefix = getErrorPrefix({timedOut, timeout, errorCode, signal, signalDescription, exitCode, isCanceled});
  718. const execaMessage = `Command ${prefix}: ${command}`;
  719. const isError = Object.prototype.toString.call(error) === '[object Error]';
  720. const shortMessage = isError ? `${execaMessage}\n${error.message}` : execaMessage;
  721. const message = [shortMessage, stderr, stdout].filter(Boolean).join('\n');
  722. if (isError) {
  723. error.originalMessage = error.message;
  724. error.message = message;
  725. } else {
  726. error = new Error(message);
  727. }
  728. error.shortMessage = shortMessage;
  729. error.command = command;
  730. error.escapedCommand = escapedCommand;
  731. error.exitCode = exitCode;
  732. error.signal = signal;
  733. error.signalDescription = signalDescription;
  734. error.stdout = stdout;
  735. error.stderr = stderr;
  736. if (all !== undefined) {
  737. error.all = all;
  738. }
  739. if ('bufferedData' in error) {
  740. delete error.bufferedData;
  741. }
  742. error.failed = true;
  743. error.timedOut = Boolean(timedOut);
  744. error.isCanceled = isCanceled;
  745. error.killed = killed && !timedOut;
  746. return error;
  747. };
  748. var error = makeError$1;
  749. var stdio = {exports: {}};
  750. const aliases = ['stdin', 'stdout', 'stderr'];
  751. const hasAlias = options => aliases.some(alias => options[alias] !== undefined);
  752. const normalizeStdio$1 = options => {
  753. if (!options) {
  754. return;
  755. }
  756. const {stdio} = options;
  757. if (stdio === undefined) {
  758. return aliases.map(alias => options[alias]);
  759. }
  760. if (hasAlias(options)) {
  761. throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${aliases.map(alias => `\`${alias}\``).join(', ')}`);
  762. }
  763. if (typeof stdio === 'string') {
  764. return stdio;
  765. }
  766. if (!Array.isArray(stdio)) {
  767. throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof stdio}\``);
  768. }
  769. const length = Math.max(stdio.length, aliases.length);
  770. return Array.from({length}, (value, index) => stdio[index]);
  771. };
  772. stdio.exports = normalizeStdio$1;
  773. // `ipc` is pushed unless it is already present
  774. stdio.exports.node = options => {
  775. const stdio = normalizeStdio$1(options);
  776. if (stdio === 'ipc') {
  777. return 'ipc';
  778. }
  779. if (stdio === undefined || typeof stdio === 'string') {
  780. return [stdio, stdio, stdio, 'ipc'];
  781. }
  782. if (stdio.includes('ipc')) {
  783. return stdio;
  784. }
  785. return [...stdio, 'ipc'];
  786. };
  787. const os = require$$0;
  788. const onExit = signalExit.exports;
  789. const DEFAULT_FORCE_KILL_TIMEOUT = 1000 * 5;
  790. // Monkey-patches `childProcess.kill()` to add `forceKillAfterTimeout` behavior
  791. const spawnedKill$1 = (kill, signal = 'SIGTERM', options = {}) => {
  792. const killResult = kill(signal);
  793. setKillTimeout(kill, signal, options, killResult);
  794. return killResult;
  795. };
  796. const setKillTimeout = (kill, signal, options, killResult) => {
  797. if (!shouldForceKill(signal, options, killResult)) {
  798. return;
  799. }
  800. const timeout = getForceKillAfterTimeout(options);
  801. const t = setTimeout(() => {
  802. kill('SIGKILL');
  803. }, timeout);
  804. // Guarded because there's no `.unref()` when `execa` is used in the renderer
  805. // process in Electron. This cannot be tested since we don't run tests in
  806. // Electron.
  807. // istanbul ignore else
  808. if (t.unref) {
  809. t.unref();
  810. }
  811. };
  812. const shouldForceKill = (signal, {forceKillAfterTimeout}, killResult) => {
  813. return isSigterm(signal) && forceKillAfterTimeout !== false && killResult;
  814. };
  815. const isSigterm = signal => {
  816. return signal === os.constants.signals.SIGTERM ||
  817. (typeof signal === 'string' && signal.toUpperCase() === 'SIGTERM');
  818. };
  819. const getForceKillAfterTimeout = ({forceKillAfterTimeout = true}) => {
  820. if (forceKillAfterTimeout === true) {
  821. return DEFAULT_FORCE_KILL_TIMEOUT;
  822. }
  823. if (!Number.isFinite(forceKillAfterTimeout) || forceKillAfterTimeout < 0) {
  824. throw new TypeError(`Expected the \`forceKillAfterTimeout\` option to be a non-negative integer, got \`${forceKillAfterTimeout}\` (${typeof forceKillAfterTimeout})`);
  825. }
  826. return forceKillAfterTimeout;
  827. };
  828. // `childProcess.cancel()`
  829. const spawnedCancel$1 = (spawned, context) => {
  830. const killResult = spawned.kill();
  831. if (killResult) {
  832. context.isCanceled = true;
  833. }
  834. };
  835. const timeoutKill = (spawned, signal, reject) => {
  836. spawned.kill(signal);
  837. reject(Object.assign(new Error('Timed out'), {timedOut: true, signal}));
  838. };
  839. // `timeout` option handling
  840. const setupTimeout$1 = (spawned, {timeout, killSignal = 'SIGTERM'}, spawnedPromise) => {
  841. if (timeout === 0 || timeout === undefined) {
  842. return spawnedPromise;
  843. }
  844. let timeoutId;
  845. const timeoutPromise = new Promise((resolve, reject) => {
  846. timeoutId = setTimeout(() => {
  847. timeoutKill(spawned, killSignal, reject);
  848. }, timeout);
  849. });
  850. const safeSpawnedPromise = spawnedPromise.finally(() => {
  851. clearTimeout(timeoutId);
  852. });
  853. return Promise.race([timeoutPromise, safeSpawnedPromise]);
  854. };
  855. const validateTimeout$1 = ({timeout}) => {
  856. if (timeout !== undefined && (!Number.isFinite(timeout) || timeout < 0)) {
  857. throw new TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${timeout}\` (${typeof timeout})`);
  858. }
  859. };
  860. // `cleanup` option handling
  861. const setExitHandler$1 = async (spawned, {cleanup, detached}, timedPromise) => {
  862. if (!cleanup || detached) {
  863. return timedPromise;
  864. }
  865. const removeExitHandler = onExit(() => {
  866. spawned.kill();
  867. });
  868. return timedPromise.finally(() => {
  869. removeExitHandler();
  870. });
  871. };
  872. var kill = {
  873. spawnedKill: spawnedKill$1,
  874. spawnedCancel: spawnedCancel$1,
  875. setupTimeout: setupTimeout$1,
  876. validateTimeout: validateTimeout$1,
  877. setExitHandler: setExitHandler$1
  878. };
  879. const isStream$1 = stream =>
  880. stream !== null &&
  881. typeof stream === 'object' &&
  882. typeof stream.pipe === 'function';
  883. isStream$1.writable = stream =>
  884. isStream$1(stream) &&
  885. stream.writable !== false &&
  886. typeof stream._write === 'function' &&
  887. typeof stream._writableState === 'object';
  888. isStream$1.readable = stream =>
  889. isStream$1(stream) &&
  890. stream.readable !== false &&
  891. typeof stream._read === 'function' &&
  892. typeof stream._readableState === 'object';
  893. isStream$1.duplex = stream =>
  894. isStream$1.writable(stream) &&
  895. isStream$1.readable(stream);
  896. isStream$1.transform = stream =>
  897. isStream$1.duplex(stream) &&
  898. typeof stream._transform === 'function';
  899. var isStream_1 = isStream$1;
  900. const isStream = isStream_1;
  901. const getStream = getStream$1.exports;
  902. const mergeStream = mergeStream$1;
  903. // `input` option
  904. const handleInput$1 = (spawned, input) => {
  905. // Checking for stdin is workaround for https://github.com/nodejs/node/issues/26852
  906. // @todo remove `|| spawned.stdin === undefined` once we drop support for Node.js <=12.2.0
  907. if (input === undefined || spawned.stdin === undefined) {
  908. return;
  909. }
  910. if (isStream(input)) {
  911. input.pipe(spawned.stdin);
  912. } else {
  913. spawned.stdin.end(input);
  914. }
  915. };
  916. // `all` interleaves `stdout` and `stderr`
  917. const makeAllStream$1 = (spawned, {all}) => {
  918. if (!all || (!spawned.stdout && !spawned.stderr)) {
  919. return;
  920. }
  921. const mixed = mergeStream();
  922. if (spawned.stdout) {
  923. mixed.add(spawned.stdout);
  924. }
  925. if (spawned.stderr) {
  926. mixed.add(spawned.stderr);
  927. }
  928. return mixed;
  929. };
  930. // On failure, `result.stdout|stderr|all` should contain the currently buffered stream
  931. const getBufferedData = async (stream, streamPromise) => {
  932. if (!stream) {
  933. return;
  934. }
  935. stream.destroy();
  936. try {
  937. return await streamPromise;
  938. } catch (error) {
  939. return error.bufferedData;
  940. }
  941. };
  942. const getStreamPromise = (stream, {encoding, buffer, maxBuffer}) => {
  943. if (!stream || !buffer) {
  944. return;
  945. }
  946. if (encoding) {
  947. return getStream(stream, {encoding, maxBuffer});
  948. }
  949. return getStream.buffer(stream, {maxBuffer});
  950. };
  951. // Retrieve result of child process: exit code, signal, error, streams (stdout/stderr/all)
  952. const getSpawnedResult$1 = async ({stdout, stderr, all}, {encoding, buffer, maxBuffer}, processDone) => {
  953. const stdoutPromise = getStreamPromise(stdout, {encoding, buffer, maxBuffer});
  954. const stderrPromise = getStreamPromise(stderr, {encoding, buffer, maxBuffer});
  955. const allPromise = getStreamPromise(all, {encoding, buffer, maxBuffer: maxBuffer * 2});
  956. try {
  957. return await Promise.all([processDone, stdoutPromise, stderrPromise, allPromise]);
  958. } catch (error) {
  959. return Promise.all([
  960. {error, signal: error.signal, timedOut: error.timedOut},
  961. getBufferedData(stdout, stdoutPromise),
  962. getBufferedData(stderr, stderrPromise),
  963. getBufferedData(all, allPromise)
  964. ]);
  965. }
  966. };
  967. const validateInputSync$1 = ({input}) => {
  968. if (isStream(input)) {
  969. throw new TypeError('The `input` option cannot be a stream in sync mode');
  970. }
  971. };
  972. var stream = {
  973. handleInput: handleInput$1,
  974. makeAllStream: makeAllStream$1,
  975. getSpawnedResult: getSpawnedResult$1,
  976. validateInputSync: validateInputSync$1
  977. };
  978. const nativePromisePrototype = (async () => {})().constructor.prototype;
  979. const descriptors = ['then', 'catch', 'finally'].map(property => [
  980. property,
  981. Reflect.getOwnPropertyDescriptor(nativePromisePrototype, property)
  982. ]);
  983. // The return value is a mixin of `childProcess` and `Promise`
  984. const mergePromise$1 = (spawned, promise) => {
  985. for (const [property, descriptor] of descriptors) {
  986. // Starting the main `promise` is deferred to avoid consuming streams
  987. const value = typeof promise === 'function' ?
  988. (...args) => Reflect.apply(descriptor.value, promise(), args) :
  989. descriptor.value.bind(promise);
  990. Reflect.defineProperty(spawned, property, {...descriptor, value});
  991. }
  992. return spawned;
  993. };
  994. // Use promises instead of `child_process` events
  995. const getSpawnedPromise$1 = spawned => {
  996. return new Promise((resolve, reject) => {
  997. spawned.on('exit', (exitCode, signal) => {
  998. resolve({exitCode, signal});
  999. });
  1000. spawned.on('error', error => {
  1001. reject(error);
  1002. });
  1003. if (spawned.stdin) {
  1004. spawned.stdin.on('error', error => {
  1005. reject(error);
  1006. });
  1007. }
  1008. });
  1009. };
  1010. var promise = {
  1011. mergePromise: mergePromise$1,
  1012. getSpawnedPromise: getSpawnedPromise$1
  1013. };
  1014. const normalizeArgs = (file, args = []) => {
  1015. if (!Array.isArray(args)) {
  1016. return [file];
  1017. }
  1018. return [file, ...args];
  1019. };
  1020. const NO_ESCAPE_REGEXP = /^[\w.-]+$/;
  1021. const DOUBLE_QUOTES_REGEXP = /"/g;
  1022. const escapeArg = arg => {
  1023. if (typeof arg !== 'string' || NO_ESCAPE_REGEXP.test(arg)) {
  1024. return arg;
  1025. }
  1026. return `"${arg.replace(DOUBLE_QUOTES_REGEXP, '\\"')}"`;
  1027. };
  1028. const joinCommand$1 = (file, args) => {
  1029. return normalizeArgs(file, args).join(' ');
  1030. };
  1031. const getEscapedCommand$1 = (file, args) => {
  1032. return normalizeArgs(file, args).map(arg => escapeArg(arg)).join(' ');
  1033. };
  1034. const SPACES_REGEXP = / +/g;
  1035. // Handle `execa.command()`
  1036. const parseCommand$1 = command => {
  1037. const tokens = [];
  1038. for (const token of command.trim().split(SPACES_REGEXP)) {
  1039. // Allow spaces to be escaped by a backslash if not meant as a delimiter
  1040. const previousToken = tokens[tokens.length - 1];
  1041. if (previousToken && previousToken.endsWith('\\')) {
  1042. // Merge previous token with current one
  1043. tokens[tokens.length - 1] = `${previousToken.slice(0, -1)} ${token}`;
  1044. } else {
  1045. tokens.push(token);
  1046. }
  1047. }
  1048. return tokens;
  1049. };
  1050. var command = {
  1051. joinCommand: joinCommand$1,
  1052. getEscapedCommand: getEscapedCommand$1,
  1053. parseCommand: parseCommand$1
  1054. };
  1055. const path = path$2;
  1056. const childProcess = childProcess$1;
  1057. const crossSpawn = crossSpawn$1.exports;
  1058. const stripFinalNewline = stripFinalNewline$1;
  1059. const npmRunPath = npmRunPath$1.exports;
  1060. const onetime = onetime$1.exports;
  1061. const makeError = error;
  1062. const normalizeStdio = stdio.exports;
  1063. const {spawnedKill, spawnedCancel, setupTimeout, validateTimeout, setExitHandler} = kill;
  1064. const {handleInput, getSpawnedResult, makeAllStream, validateInputSync} = stream;
  1065. const {mergePromise, getSpawnedPromise} = promise;
  1066. const {joinCommand, parseCommand, getEscapedCommand} = command;
  1067. const DEFAULT_MAX_BUFFER = 1000 * 1000 * 100;
  1068. const getEnv = ({env: envOption, extendEnv, preferLocal, localDir, execPath}) => {
  1069. const env = extendEnv ? {...process.env, ...envOption} : envOption;
  1070. if (preferLocal) {
  1071. return npmRunPath.env({env, cwd: localDir, execPath});
  1072. }
  1073. return env;
  1074. };
  1075. const handleArguments = (file, args, options = {}) => {
  1076. const parsed = crossSpawn._parse(file, args, options);
  1077. file = parsed.command;
  1078. args = parsed.args;
  1079. options = parsed.options;
  1080. options = {
  1081. maxBuffer: DEFAULT_MAX_BUFFER,
  1082. buffer: true,
  1083. stripFinalNewline: true,
  1084. extendEnv: true,
  1085. preferLocal: false,
  1086. localDir: options.cwd || process.cwd(),
  1087. execPath: process.execPath,
  1088. encoding: 'utf8',
  1089. reject: true,
  1090. cleanup: true,
  1091. all: false,
  1092. windowsHide: true,
  1093. ...options
  1094. };
  1095. options.env = getEnv(options);
  1096. options.stdio = normalizeStdio(options);
  1097. if (process.platform === 'win32' && path.basename(file, '.exe') === 'cmd') {
  1098. // #116
  1099. args.unshift('/q');
  1100. }
  1101. return {file, args, options, parsed};
  1102. };
  1103. const handleOutput = (options, value, error) => {
  1104. if (typeof value !== 'string' && !Buffer.isBuffer(value)) {
  1105. // When `execa.sync()` errors, we normalize it to '' to mimic `execa()`
  1106. return error === undefined ? undefined : '';
  1107. }
  1108. if (options.stripFinalNewline) {
  1109. return stripFinalNewline(value);
  1110. }
  1111. return value;
  1112. };
  1113. const execa = (file, args, options) => {
  1114. const parsed = handleArguments(file, args, options);
  1115. const command = joinCommand(file, args);
  1116. const escapedCommand = getEscapedCommand(file, args);
  1117. validateTimeout(parsed.options);
  1118. let spawned;
  1119. try {
  1120. spawned = childProcess.spawn(parsed.file, parsed.args, parsed.options);
  1121. } catch (error) {
  1122. // Ensure the returned error is always both a promise and a child process
  1123. const dummySpawned = new childProcess.ChildProcess();
  1124. const errorPromise = Promise.reject(makeError({
  1125. error,
  1126. stdout: '',
  1127. stderr: '',
  1128. all: '',
  1129. command,
  1130. escapedCommand,
  1131. parsed,
  1132. timedOut: false,
  1133. isCanceled: false,
  1134. killed: false
  1135. }));
  1136. return mergePromise(dummySpawned, errorPromise);
  1137. }
  1138. const spawnedPromise = getSpawnedPromise(spawned);
  1139. const timedPromise = setupTimeout(spawned, parsed.options, spawnedPromise);
  1140. const processDone = setExitHandler(spawned, parsed.options, timedPromise);
  1141. const context = {isCanceled: false};
  1142. spawned.kill = spawnedKill.bind(null, spawned.kill.bind(spawned));
  1143. spawned.cancel = spawnedCancel.bind(null, spawned, context);
  1144. const handlePromise = async () => {
  1145. const [{error, exitCode, signal, timedOut}, stdoutResult, stderrResult, allResult] = await getSpawnedResult(spawned, parsed.options, processDone);
  1146. const stdout = handleOutput(parsed.options, stdoutResult);
  1147. const stderr = handleOutput(parsed.options, stderrResult);
  1148. const all = handleOutput(parsed.options, allResult);
  1149. if (error || exitCode !== 0 || signal !== null) {
  1150. const returnedError = makeError({
  1151. error,
  1152. exitCode,
  1153. signal,
  1154. stdout,
  1155. stderr,
  1156. all,
  1157. command,
  1158. escapedCommand,
  1159. parsed,
  1160. timedOut,
  1161. isCanceled: context.isCanceled,
  1162. killed: spawned.killed
  1163. });
  1164. if (!parsed.options.reject) {
  1165. return returnedError;
  1166. }
  1167. throw returnedError;
  1168. }
  1169. return {
  1170. command,
  1171. escapedCommand,
  1172. exitCode: 0,
  1173. stdout,
  1174. stderr,
  1175. all,
  1176. failed: false,
  1177. timedOut: false,
  1178. isCanceled: false,
  1179. killed: false
  1180. };
  1181. };
  1182. const handlePromiseOnce = onetime(handlePromise);
  1183. handleInput(spawned, parsed.options.input);
  1184. spawned.all = makeAllStream(spawned, parsed.options);
  1185. return mergePromise(spawned, handlePromiseOnce);
  1186. };
  1187. execa$1.exports = execa;
  1188. execa$1.exports.sync = (file, args, options) => {
  1189. const parsed = handleArguments(file, args, options);
  1190. const command = joinCommand(file, args);
  1191. const escapedCommand = getEscapedCommand(file, args);
  1192. validateInputSync(parsed.options);
  1193. let result;
  1194. try {
  1195. result = childProcess.spawnSync(parsed.file, parsed.args, parsed.options);
  1196. } catch (error) {
  1197. throw makeError({
  1198. error,
  1199. stdout: '',
  1200. stderr: '',
  1201. all: '',
  1202. command,
  1203. escapedCommand,
  1204. parsed,
  1205. timedOut: false,
  1206. isCanceled: false,
  1207. killed: false
  1208. });
  1209. }
  1210. const stdout = handleOutput(parsed.options, result.stdout, result.error);
  1211. const stderr = handleOutput(parsed.options, result.stderr, result.error);
  1212. if (result.error || result.status !== 0 || result.signal !== null) {
  1213. const error = makeError({
  1214. stdout,
  1215. stderr,
  1216. error: result.error,
  1217. signal: result.signal,
  1218. exitCode: result.status,
  1219. command,
  1220. escapedCommand,
  1221. parsed,
  1222. timedOut: result.error && result.error.code === 'ETIMEDOUT',
  1223. isCanceled: false,
  1224. killed: result.signal !== null
  1225. });
  1226. if (!parsed.options.reject) {
  1227. return error;
  1228. }
  1229. throw error;
  1230. }
  1231. return {
  1232. command,
  1233. escapedCommand,
  1234. exitCode: 0,
  1235. stdout,
  1236. stderr,
  1237. failed: false,
  1238. timedOut: false,
  1239. isCanceled: false,
  1240. killed: false
  1241. };
  1242. };
  1243. execa$1.exports.command = (command, options) => {
  1244. const [file, ...args] = parseCommand(command);
  1245. return execa(file, args, options);
  1246. };
  1247. execa$1.exports.commandSync = (command, options) => {
  1248. const [file, ...args] = parseCommand(command);
  1249. return execa.sync(file, args, options);
  1250. };
  1251. execa$1.exports.node = (scriptPath, args, options = {}) => {
  1252. if (args && !Array.isArray(args) && typeof args === 'object') {
  1253. options = args;
  1254. args = [];
  1255. }
  1256. const stdio = normalizeStdio.node(options);
  1257. const defaultExecArgv = process.execArgv.filter(arg => !arg.startsWith('--inspect'));
  1258. const {
  1259. nodePath = process.execPath,
  1260. nodeOptions = defaultExecArgv
  1261. } = options;
  1262. return execa(
  1263. nodePath,
  1264. [
  1265. ...nodeOptions,
  1266. scriptPath,
  1267. ...(Array.isArray(args) ? args : [])
  1268. ],
  1269. {
  1270. ...options,
  1271. stdin: undefined,
  1272. stdout: undefined,
  1273. stderr: undefined,
  1274. stdio,
  1275. shell: false
  1276. }
  1277. );
  1278. };
  1279. // src/detect.ts
  1280. var LOCKS = {
  1281. "pnpm-lock.yaml": "pnpm",
  1282. "yarn.lock": "yarn",
  1283. "package-lock.json": "npm"
  1284. };
  1285. async function detectPackageManager(cwd = process.cwd()) {
  1286. const result = await findUp(Object.keys(LOCKS), { cwd });
  1287. const agent = result ? LOCKS[path$2.basename(result)] : null;
  1288. return agent;
  1289. }
  1290. async function installPackage(names, options = {}) {
  1291. const agent = options.packageManager || await detectPackageManager(options.cwd) || "npm";
  1292. if (!Array.isArray(names))
  1293. names = [names];
  1294. const args = options.additionalArgs || [];
  1295. if (options.preferOffline)
  1296. args.unshift("--prefer-offline");
  1297. return execa$1.exports(agent, [
  1298. agent === "yarn" ? "add" : "install",
  1299. options.dev ? "-D" : "",
  1300. ...args,
  1301. ...names
  1302. ].filter(Boolean), {
  1303. stdio: options.silent ? "ignore" : "inherit",
  1304. cwd: options.cwd
  1305. });
  1306. }
  1307. export { detectPackageManager, installPackage };