@catladder/cli 0.0.0-main-fb266e7f → 0.0.0-main-6545ebf1

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.
@@ -4469,10 +4469,9 @@ const createBuildJobArtifacts = (context) => {
4469
4469
  const paths = context.type === "workspace"
4470
4470
  ? context.components.flatMap((c) => getArtifactsPathForComponent(c))
4471
4471
  : getArtifactsPathForComponent(context, ["__build_info.json"]);
4472
- // esxclude .env files if generated
4473
4472
  const exclude = context.type === "workspace"
4474
- ? context.components.flatMap((c) => getDotEnvPathsForComponent(c))
4475
- : getDotEnvPathsForComponent(context);
4473
+ ? context.components.flatMap((c) => getAllArtifactExcludePathsForComponent(c))
4474
+ : getAllArtifactExcludePathsForComponent(context);
4476
4475
  return {
4477
4476
  paths: (0, lodash_1.uniq)(paths).sort((a, b) => a.localeCompare(b)),
4478
4477
  ...(exclude.length > 0 ? { exclude } : {}),
@@ -4488,12 +4487,10 @@ const createBuildJobArtifacts = (context) => {
4488
4487
  };
4489
4488
  };
4490
4489
  exports.createBuildJobArtifacts = createBuildJobArtifacts;
4491
- const getArtifactsPathForComponent = (c, additionalPaths) => {
4490
+ const _getArtifactPathsForComponent = (c, configKey, additionalPaths) => {
4492
4491
  var _a, _b;
4493
4492
  return (_b = [
4494
- ...(c.build.type !== "disabled"
4495
- ? ((_a = c.build.config.artifactsPaths) !== null && _a !== void 0 ? _a : [])
4496
- : []),
4493
+ ...(c.build.type !== "disabled" ? ((_a = c.build.config[configKey]) !== null && _a !== void 0 ? _a : []) : []),
4497
4494
  ...(additionalPaths !== null && additionalPaths !== void 0 ? additionalPaths : []),
4498
4495
  ]) === null || _b === void 0 ? void 0 : _b.flatMap((artifact) => c.build
4499
4496
  // in theory, we only need "direct",
@@ -4502,6 +4499,18 @@ const getArtifactsPathForComponent = (c, additionalPaths) => {
4502
4499
  .getComponentDirs("all")
4503
4500
  .flatMap((cDir) => (0, path_1.join)(cDir, artifact)));
4504
4501
  };
4502
+ const getArtifactsPathForComponent = (c, additionalPaths) => {
4503
+ return _getArtifactPathsForComponent(c, "artifactsPaths", additionalPaths);
4504
+ };
4505
+ const getAllArtifactExcludePathsForComponent = (c) => {
4506
+ return [
4507
+ ...getDotEnvPathsForComponent(c), // always exclude .env files
4508
+ ...getArtifactExcludePathsForComponent(c),
4509
+ ];
4510
+ };
4511
+ const getArtifactExcludePathsForComponent = (c, additionalPaths) => {
4512
+ return _getArtifactPathsForComponent(c, "artifactsExcludePaths", additionalPaths);
4513
+ };
4505
4514
  const getDotEnvPathsForComponent = (c) => {
4506
4515
  if ((0, writeDotEnv_1.componentContextNeedsBuildTimeDotEnv)(c)) {
4507
4516
  return [(0, path_1.join)(c.build.dir, ".env")];
@@ -125760,7 +125769,7 @@ module.exports = parse;
125760
125769
 
125761
125770
 
125762
125771
  var path = __nccwpck_require__(71017);
125763
- var which = __nccwpck_require__(63623);
125772
+ var which = __nccwpck_require__(73672);
125764
125773
  var LRU = __nccwpck_require__(64144);
125765
125774
 
125766
125775
  var commandCache = new LRU({ max: 50, maxAge: 30 * 1000 }); // Cache just for 30sec
@@ -126266,6 +126275,148 @@ function Entry (key, value, length, now, maxAge) {
126266
126275
  }
126267
126276
 
126268
126277
 
126278
+ /***/ }),
126279
+
126280
+ /***/ 73672:
126281
+ /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
126282
+
126283
+ module.exports = which
126284
+ which.sync = whichSync
126285
+
126286
+ var isWindows = process.platform === 'win32' ||
126287
+ process.env.OSTYPE === 'cygwin' ||
126288
+ process.env.OSTYPE === 'msys'
126289
+
126290
+ var path = __nccwpck_require__(71017)
126291
+ var COLON = isWindows ? ';' : ':'
126292
+ var isexe = __nccwpck_require__(15930)
126293
+
126294
+ function getNotFoundError (cmd) {
126295
+ var er = new Error('not found: ' + cmd)
126296
+ er.code = 'ENOENT'
126297
+
126298
+ return er
126299
+ }
126300
+
126301
+ function getPathInfo (cmd, opt) {
126302
+ var colon = opt.colon || COLON
126303
+ var pathEnv = opt.path || process.env.PATH || ''
126304
+ var pathExt = ['']
126305
+
126306
+ pathEnv = pathEnv.split(colon)
126307
+
126308
+ var pathExtExe = ''
126309
+ if (isWindows) {
126310
+ pathEnv.unshift(process.cwd())
126311
+ pathExtExe = (opt.pathExt || process.env.PATHEXT || '.EXE;.CMD;.BAT;.COM')
126312
+ pathExt = pathExtExe.split(colon)
126313
+
126314
+
126315
+ // Always test the cmd itself first. isexe will check to make sure
126316
+ // it's found in the pathExt set.
126317
+ if (cmd.indexOf('.') !== -1 && pathExt[0] !== '')
126318
+ pathExt.unshift('')
126319
+ }
126320
+
126321
+ // If it has a slash, then we don't bother searching the pathenv.
126322
+ // just check the file itself, and that's it.
126323
+ if (cmd.match(/\//) || isWindows && cmd.match(/\\/))
126324
+ pathEnv = ['']
126325
+
126326
+ return {
126327
+ env: pathEnv,
126328
+ ext: pathExt,
126329
+ extExe: pathExtExe
126330
+ }
126331
+ }
126332
+
126333
+ function which (cmd, opt, cb) {
126334
+ if (typeof opt === 'function') {
126335
+ cb = opt
126336
+ opt = {}
126337
+ }
126338
+
126339
+ var info = getPathInfo(cmd, opt)
126340
+ var pathEnv = info.env
126341
+ var pathExt = info.ext
126342
+ var pathExtExe = info.extExe
126343
+ var found = []
126344
+
126345
+ ;(function F (i, l) {
126346
+ if (i === l) {
126347
+ if (opt.all && found.length)
126348
+ return cb(null, found)
126349
+ else
126350
+ return cb(getNotFoundError(cmd))
126351
+ }
126352
+
126353
+ var pathPart = pathEnv[i]
126354
+ if (pathPart.charAt(0) === '"' && pathPart.slice(-1) === '"')
126355
+ pathPart = pathPart.slice(1, -1)
126356
+
126357
+ var p = path.join(pathPart, cmd)
126358
+ if (!pathPart && (/^\.[\\\/]/).test(cmd)) {
126359
+ p = cmd.slice(0, 2) + p
126360
+ }
126361
+ ;(function E (ii, ll) {
126362
+ if (ii === ll) return F(i + 1, l)
126363
+ var ext = pathExt[ii]
126364
+ isexe(p + ext, { pathExt: pathExtExe }, function (er, is) {
126365
+ if (!er && is) {
126366
+ if (opt.all)
126367
+ found.push(p + ext)
126368
+ else
126369
+ return cb(null, p + ext)
126370
+ }
126371
+ return E(ii + 1, ll)
126372
+ })
126373
+ })(0, pathExt.length)
126374
+ })(0, pathEnv.length)
126375
+ }
126376
+
126377
+ function whichSync (cmd, opt) {
126378
+ opt = opt || {}
126379
+
126380
+ var info = getPathInfo(cmd, opt)
126381
+ var pathEnv = info.env
126382
+ var pathExt = info.ext
126383
+ var pathExtExe = info.extExe
126384
+ var found = []
126385
+
126386
+ for (var i = 0, l = pathEnv.length; i < l; i ++) {
126387
+ var pathPart = pathEnv[i]
126388
+ if (pathPart.charAt(0) === '"' && pathPart.slice(-1) === '"')
126389
+ pathPart = pathPart.slice(1, -1)
126390
+
126391
+ var p = path.join(pathPart, cmd)
126392
+ if (!pathPart && /^\.[\\\/]/.test(cmd)) {
126393
+ p = cmd.slice(0, 2) + p
126394
+ }
126395
+ for (var j = 0, ll = pathExt.length; j < ll; j ++) {
126396
+ var cur = p + pathExt[j]
126397
+ var is
126398
+ try {
126399
+ is = isexe.sync(cur, { pathExt: pathExtExe })
126400
+ if (is) {
126401
+ if (opt.all)
126402
+ found.push(cur)
126403
+ else
126404
+ return cur
126405
+ }
126406
+ } catch (ex) {}
126407
+ }
126408
+ }
126409
+
126410
+ if (opt.all && found.length)
126411
+ return found
126412
+
126413
+ if (opt.nothrow)
126414
+ return null
126415
+
126416
+ throw getNotFoundError(cmd)
126417
+ }
126418
+
126419
+
126269
126420
  /***/ }),
126270
126421
 
126271
126422
  /***/ 4071:
@@ -127555,7 +127706,7 @@ module.exports = readShebang;
127555
127706
 
127556
127707
 
127557
127708
  const path = __nccwpck_require__(71017);
127558
- const which = __nccwpck_require__(63623);
127709
+ const which = __nccwpck_require__(87698);
127559
127710
  const pathKey = __nccwpck_require__(55003)();
127560
127711
 
127561
127712
  function resolveCommandAttempt(parsed, withoutPathExt) {
@@ -129807,6 +129958,148 @@ module.exports = function (str) {
129807
129958
  module.exports = /^#!.*/;
129808
129959
 
129809
129960
 
129961
+ /***/ }),
129962
+
129963
+ /***/ 87698:
129964
+ /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
129965
+
129966
+ module.exports = which
129967
+ which.sync = whichSync
129968
+
129969
+ var isWindows = process.platform === 'win32' ||
129970
+ process.env.OSTYPE === 'cygwin' ||
129971
+ process.env.OSTYPE === 'msys'
129972
+
129973
+ var path = __nccwpck_require__(71017)
129974
+ var COLON = isWindows ? ';' : ':'
129975
+ var isexe = __nccwpck_require__(15930)
129976
+
129977
+ function getNotFoundError (cmd) {
129978
+ var er = new Error('not found: ' + cmd)
129979
+ er.code = 'ENOENT'
129980
+
129981
+ return er
129982
+ }
129983
+
129984
+ function getPathInfo (cmd, opt) {
129985
+ var colon = opt.colon || COLON
129986
+ var pathEnv = opt.path || process.env.PATH || ''
129987
+ var pathExt = ['']
129988
+
129989
+ pathEnv = pathEnv.split(colon)
129990
+
129991
+ var pathExtExe = ''
129992
+ if (isWindows) {
129993
+ pathEnv.unshift(process.cwd())
129994
+ pathExtExe = (opt.pathExt || process.env.PATHEXT || '.EXE;.CMD;.BAT;.COM')
129995
+ pathExt = pathExtExe.split(colon)
129996
+
129997
+
129998
+ // Always test the cmd itself first. isexe will check to make sure
129999
+ // it's found in the pathExt set.
130000
+ if (cmd.indexOf('.') !== -1 && pathExt[0] !== '')
130001
+ pathExt.unshift('')
130002
+ }
130003
+
130004
+ // If it has a slash, then we don't bother searching the pathenv.
130005
+ // just check the file itself, and that's it.
130006
+ if (cmd.match(/\//) || isWindows && cmd.match(/\\/))
130007
+ pathEnv = ['']
130008
+
130009
+ return {
130010
+ env: pathEnv,
130011
+ ext: pathExt,
130012
+ extExe: pathExtExe
130013
+ }
130014
+ }
130015
+
130016
+ function which (cmd, opt, cb) {
130017
+ if (typeof opt === 'function') {
130018
+ cb = opt
130019
+ opt = {}
130020
+ }
130021
+
130022
+ var info = getPathInfo(cmd, opt)
130023
+ var pathEnv = info.env
130024
+ var pathExt = info.ext
130025
+ var pathExtExe = info.extExe
130026
+ var found = []
130027
+
130028
+ ;(function F (i, l) {
130029
+ if (i === l) {
130030
+ if (opt.all && found.length)
130031
+ return cb(null, found)
130032
+ else
130033
+ return cb(getNotFoundError(cmd))
130034
+ }
130035
+
130036
+ var pathPart = pathEnv[i]
130037
+ if (pathPart.charAt(0) === '"' && pathPart.slice(-1) === '"')
130038
+ pathPart = pathPart.slice(1, -1)
130039
+
130040
+ var p = path.join(pathPart, cmd)
130041
+ if (!pathPart && (/^\.[\\\/]/).test(cmd)) {
130042
+ p = cmd.slice(0, 2) + p
130043
+ }
130044
+ ;(function E (ii, ll) {
130045
+ if (ii === ll) return F(i + 1, l)
130046
+ var ext = pathExt[ii]
130047
+ isexe(p + ext, { pathExt: pathExtExe }, function (er, is) {
130048
+ if (!er && is) {
130049
+ if (opt.all)
130050
+ found.push(p + ext)
130051
+ else
130052
+ return cb(null, p + ext)
130053
+ }
130054
+ return E(ii + 1, ll)
130055
+ })
130056
+ })(0, pathExt.length)
130057
+ })(0, pathEnv.length)
130058
+ }
130059
+
130060
+ function whichSync (cmd, opt) {
130061
+ opt = opt || {}
130062
+
130063
+ var info = getPathInfo(cmd, opt)
130064
+ var pathEnv = info.env
130065
+ var pathExt = info.ext
130066
+ var pathExtExe = info.extExe
130067
+ var found = []
130068
+
130069
+ for (var i = 0, l = pathEnv.length; i < l; i ++) {
130070
+ var pathPart = pathEnv[i]
130071
+ if (pathPart.charAt(0) === '"' && pathPart.slice(-1) === '"')
130072
+ pathPart = pathPart.slice(1, -1)
130073
+
130074
+ var p = path.join(pathPart, cmd)
130075
+ if (!pathPart && /^\.[\\\/]/.test(cmd)) {
130076
+ p = cmd.slice(0, 2) + p
130077
+ }
130078
+ for (var j = 0, ll = pathExt.length; j < ll; j ++) {
130079
+ var cur = p + pathExt[j]
130080
+ var is
130081
+ try {
130082
+ is = isexe.sync(cur, { pathExt: pathExtExe })
130083
+ if (is) {
130084
+ if (opt.all)
130085
+ found.push(cur)
130086
+ else
130087
+ return cur
130088
+ }
130089
+ } catch (ex) {}
130090
+ }
130091
+ }
130092
+
130093
+ if (opt.all && found.length)
130094
+ return found
130095
+
130096
+ if (opt.nothrow)
130097
+ return null
130098
+
130099
+ throw getNotFoundError(cmd)
130100
+ }
130101
+
130102
+
129810
130103
  /***/ }),
129811
130104
 
129812
130105
  /***/ 60482:
@@ -141415,7 +141708,7 @@ module.exports = readShebang;
141415
141708
 
141416
141709
 
141417
141710
  const path = __nccwpck_require__(71017);
141418
- const which = __nccwpck_require__(28995);
141711
+ const which = __nccwpck_require__(63623);
141419
141712
  const getPathKey = __nccwpck_require__(20154);
141420
141713
 
141421
141714
  function resolveCommandAttempt(parsed, withoutPathExt) {
@@ -141466,138 +141759,6 @@ function resolveCommand(parsed) {
141466
141759
  module.exports = resolveCommand;
141467
141760
 
141468
141761
 
141469
- /***/ }),
141470
-
141471
- /***/ 28995:
141472
- /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
141473
-
141474
- const isWindows = process.platform === 'win32' ||
141475
- process.env.OSTYPE === 'cygwin' ||
141476
- process.env.OSTYPE === 'msys'
141477
-
141478
- const path = __nccwpck_require__(71017)
141479
- const COLON = isWindows ? ';' : ':'
141480
- const isexe = __nccwpck_require__(15930)
141481
-
141482
- const getNotFoundError = (cmd) =>
141483
- Object.assign(new Error(`not found: ${cmd}`), { code: 'ENOENT' })
141484
-
141485
- const getPathInfo = (cmd, opt) => {
141486
- const colon = opt.colon || COLON
141487
-
141488
- // If it has a slash, then we don't bother searching the pathenv.
141489
- // just check the file itself, and that's it.
141490
- const pathEnv = cmd.match(/\//) || isWindows && cmd.match(/\\/) ? ['']
141491
- : (
141492
- [
141493
- // windows always checks the cwd first
141494
- ...(isWindows ? [process.cwd()] : []),
141495
- ...(opt.path || process.env.PATH ||
141496
- /* istanbul ignore next: very unusual */ '').split(colon),
141497
- ]
141498
- )
141499
- const pathExtExe = isWindows
141500
- ? opt.pathExt || process.env.PATHEXT || '.EXE;.CMD;.BAT;.COM'
141501
- : ''
141502
- const pathExt = isWindows ? pathExtExe.split(colon) : ['']
141503
-
141504
- if (isWindows) {
141505
- if (cmd.indexOf('.') !== -1 && pathExt[0] !== '')
141506
- pathExt.unshift('')
141507
- }
141508
-
141509
- return {
141510
- pathEnv,
141511
- pathExt,
141512
- pathExtExe,
141513
- }
141514
- }
141515
-
141516
- const which = (cmd, opt, cb) => {
141517
- if (typeof opt === 'function') {
141518
- cb = opt
141519
- opt = {}
141520
- }
141521
- if (!opt)
141522
- opt = {}
141523
-
141524
- const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt)
141525
- const found = []
141526
-
141527
- const step = i => new Promise((resolve, reject) => {
141528
- if (i === pathEnv.length)
141529
- return opt.all && found.length ? resolve(found)
141530
- : reject(getNotFoundError(cmd))
141531
-
141532
- const ppRaw = pathEnv[i]
141533
- const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw
141534
-
141535
- const pCmd = path.join(pathPart, cmd)
141536
- const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd
141537
- : pCmd
141538
-
141539
- resolve(subStep(p, i, 0))
141540
- })
141541
-
141542
- const subStep = (p, i, ii) => new Promise((resolve, reject) => {
141543
- if (ii === pathExt.length)
141544
- return resolve(step(i + 1))
141545
- const ext = pathExt[ii]
141546
- isexe(p + ext, { pathExt: pathExtExe }, (er, is) => {
141547
- if (!er && is) {
141548
- if (opt.all)
141549
- found.push(p + ext)
141550
- else
141551
- return resolve(p + ext)
141552
- }
141553
- return resolve(subStep(p, i, ii + 1))
141554
- })
141555
- })
141556
-
141557
- return cb ? step(0).then(res => cb(null, res), cb) : step(0)
141558
- }
141559
-
141560
- const whichSync = (cmd, opt) => {
141561
- opt = opt || {}
141562
-
141563
- const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt)
141564
- const found = []
141565
-
141566
- for (let i = 0; i < pathEnv.length; i ++) {
141567
- const ppRaw = pathEnv[i]
141568
- const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw
141569
-
141570
- const pCmd = path.join(pathPart, cmd)
141571
- const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd
141572
- : pCmd
141573
-
141574
- for (let j = 0; j < pathExt.length; j ++) {
141575
- const cur = p + pathExt[j]
141576
- try {
141577
- const is = isexe.sync(cur, { pathExt: pathExtExe })
141578
- if (is) {
141579
- if (opt.all)
141580
- found.push(cur)
141581
- else
141582
- return cur
141583
- }
141584
- } catch (ex) {}
141585
- }
141586
- }
141587
-
141588
- if (opt.all && found.length)
141589
- return found
141590
-
141591
- if (opt.nothrow)
141592
- return null
141593
-
141594
- throw getNotFoundError(cmd)
141595
- }
141596
-
141597
- module.exports = which
141598
- which.sync = whichSync
141599
-
141600
-
141601
141762
  /***/ }),
141602
141763
 
141603
141764
  /***/ 95509:
@@ -293597,123 +293758,110 @@ module.exports.implForWrapper = function (wrapper) {
293597
293758
  /***/ 63623:
293598
293759
  /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
293599
293760
 
293600
- module.exports = which
293601
- which.sync = whichSync
293602
-
293603
- var isWindows = process.platform === 'win32' ||
293761
+ const isWindows = process.platform === 'win32' ||
293604
293762
  process.env.OSTYPE === 'cygwin' ||
293605
293763
  process.env.OSTYPE === 'msys'
293606
293764
 
293607
- var path = __nccwpck_require__(71017)
293608
- var COLON = isWindows ? ';' : ':'
293609
- var isexe = __nccwpck_require__(15930)
293610
-
293611
- function getNotFoundError (cmd) {
293612
- var er = new Error('not found: ' + cmd)
293613
- er.code = 'ENOENT'
293765
+ const path = __nccwpck_require__(71017)
293766
+ const COLON = isWindows ? ';' : ':'
293767
+ const isexe = __nccwpck_require__(15930)
293614
293768
 
293615
- return er
293616
- }
293769
+ const getNotFoundError = (cmd) =>
293770
+ Object.assign(new Error(`not found: ${cmd}`), { code: 'ENOENT' })
293617
293771
 
293618
- function getPathInfo (cmd, opt) {
293619
- var colon = opt.colon || COLON
293620
- var pathEnv = opt.path || process.env.PATH || ''
293621
- var pathExt = ['']
293772
+ const getPathInfo = (cmd, opt) => {
293773
+ const colon = opt.colon || COLON
293622
293774
 
293623
- pathEnv = pathEnv.split(colon)
293775
+ // If it has a slash, then we don't bother searching the pathenv.
293776
+ // just check the file itself, and that's it.
293777
+ const pathEnv = cmd.match(/\//) || isWindows && cmd.match(/\\/) ? ['']
293778
+ : (
293779
+ [
293780
+ // windows always checks the cwd first
293781
+ ...(isWindows ? [process.cwd()] : []),
293782
+ ...(opt.path || process.env.PATH ||
293783
+ /* istanbul ignore next: very unusual */ '').split(colon),
293784
+ ]
293785
+ )
293786
+ const pathExtExe = isWindows
293787
+ ? opt.pathExt || process.env.PATHEXT || '.EXE;.CMD;.BAT;.COM'
293788
+ : ''
293789
+ const pathExt = isWindows ? pathExtExe.split(colon) : ['']
293624
293790
 
293625
- var pathExtExe = ''
293626
293791
  if (isWindows) {
293627
- pathEnv.unshift(process.cwd())
293628
- pathExtExe = (opt.pathExt || process.env.PATHEXT || '.EXE;.CMD;.BAT;.COM')
293629
- pathExt = pathExtExe.split(colon)
293630
-
293631
-
293632
- // Always test the cmd itself first. isexe will check to make sure
293633
- // it's found in the pathExt set.
293634
293792
  if (cmd.indexOf('.') !== -1 && pathExt[0] !== '')
293635
293793
  pathExt.unshift('')
293636
293794
  }
293637
293795
 
293638
- // If it has a slash, then we don't bother searching the pathenv.
293639
- // just check the file itself, and that's it.
293640
- if (cmd.match(/\//) || isWindows && cmd.match(/\\/))
293641
- pathEnv = ['']
293642
-
293643
293796
  return {
293644
- env: pathEnv,
293645
- ext: pathExt,
293646
- extExe: pathExtExe
293797
+ pathEnv,
293798
+ pathExt,
293799
+ pathExtExe,
293647
293800
  }
293648
293801
  }
293649
293802
 
293650
- function which (cmd, opt, cb) {
293803
+ const which = (cmd, opt, cb) => {
293651
293804
  if (typeof opt === 'function') {
293652
293805
  cb = opt
293653
293806
  opt = {}
293654
293807
  }
293808
+ if (!opt)
293809
+ opt = {}
293655
293810
 
293656
- var info = getPathInfo(cmd, opt)
293657
- var pathEnv = info.env
293658
- var pathExt = info.ext
293659
- var pathExtExe = info.extExe
293660
- var found = []
293811
+ const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt)
293812
+ const found = []
293661
293813
 
293662
- ;(function F (i, l) {
293663
- if (i === l) {
293664
- if (opt.all && found.length)
293665
- return cb(null, found)
293666
- else
293667
- return cb(getNotFoundError(cmd))
293668
- }
293814
+ const step = i => new Promise((resolve, reject) => {
293815
+ if (i === pathEnv.length)
293816
+ return opt.all && found.length ? resolve(found)
293817
+ : reject(getNotFoundError(cmd))
293669
293818
 
293670
- var pathPart = pathEnv[i]
293671
- if (pathPart.charAt(0) === '"' && pathPart.slice(-1) === '"')
293672
- pathPart = pathPart.slice(1, -1)
293819
+ const ppRaw = pathEnv[i]
293820
+ const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw
293673
293821
 
293674
- var p = path.join(pathPart, cmd)
293675
- if (!pathPart && (/^\.[\\\/]/).test(cmd)) {
293676
- p = cmd.slice(0, 2) + p
293677
- }
293678
- ;(function E (ii, ll) {
293679
- if (ii === ll) return F(i + 1, l)
293680
- var ext = pathExt[ii]
293681
- isexe(p + ext, { pathExt: pathExtExe }, function (er, is) {
293682
- if (!er && is) {
293683
- if (opt.all)
293684
- found.push(p + ext)
293685
- else
293686
- return cb(null, p + ext)
293687
- }
293688
- return E(ii + 1, ll)
293689
- })
293690
- })(0, pathExt.length)
293691
- })(0, pathEnv.length)
293822
+ const pCmd = path.join(pathPart, cmd)
293823
+ const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd
293824
+ : pCmd
293825
+
293826
+ resolve(subStep(p, i, 0))
293827
+ })
293828
+
293829
+ const subStep = (p, i, ii) => new Promise((resolve, reject) => {
293830
+ if (ii === pathExt.length)
293831
+ return resolve(step(i + 1))
293832
+ const ext = pathExt[ii]
293833
+ isexe(p + ext, { pathExt: pathExtExe }, (er, is) => {
293834
+ if (!er && is) {
293835
+ if (opt.all)
293836
+ found.push(p + ext)
293837
+ else
293838
+ return resolve(p + ext)
293839
+ }
293840
+ return resolve(subStep(p, i, ii + 1))
293841
+ })
293842
+ })
293843
+
293844
+ return cb ? step(0).then(res => cb(null, res), cb) : step(0)
293692
293845
  }
293693
293846
 
293694
- function whichSync (cmd, opt) {
293847
+ const whichSync = (cmd, opt) => {
293695
293848
  opt = opt || {}
293696
293849
 
293697
- var info = getPathInfo(cmd, opt)
293698
- var pathEnv = info.env
293699
- var pathExt = info.ext
293700
- var pathExtExe = info.extExe
293701
- var found = []
293850
+ const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt)
293851
+ const found = []
293702
293852
 
293703
- for (var i = 0, l = pathEnv.length; i < l; i ++) {
293704
- var pathPart = pathEnv[i]
293705
- if (pathPart.charAt(0) === '"' && pathPart.slice(-1) === '"')
293706
- pathPart = pathPart.slice(1, -1)
293853
+ for (let i = 0; i < pathEnv.length; i ++) {
293854
+ const ppRaw = pathEnv[i]
293855
+ const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw
293707
293856
 
293708
- var p = path.join(pathPart, cmd)
293709
- if (!pathPart && /^\.[\\\/]/.test(cmd)) {
293710
- p = cmd.slice(0, 2) + p
293711
- }
293712
- for (var j = 0, ll = pathExt.length; j < ll; j ++) {
293713
- var cur = p + pathExt[j]
293714
- var is
293857
+ const pCmd = path.join(pathPart, cmd)
293858
+ const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd
293859
+ : pCmd
293860
+
293861
+ for (let j = 0; j < pathExt.length; j ++) {
293862
+ const cur = p + pathExt[j]
293715
293863
  try {
293716
- is = isexe.sync(cur, { pathExt: pathExtExe })
293864
+ const is = isexe.sync(cur, { pathExt: pathExtExe })
293717
293865
  if (is) {
293718
293866
  if (opt.all)
293719
293867
  found.push(cur)
@@ -293733,6 +293881,9 @@ function whichSync (cmd, opt) {
293733
293881
  throw getNotFoundError(cmd)
293734
293882
  }
293735
293883
 
293884
+ module.exports = which
293885
+ which.sync = whichSync
293886
+
293736
293887
 
293737
293888
  /***/ }),
293738
293889