@catladder/cli 0.0.0-main-fb266e7f → 0.0.0-main-49cf4dd9

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")];
@@ -5233,6 +5242,7 @@ exports.BUILD_TYPES = {
5233
5242
  buildCommand: "yarn build",
5234
5243
  startCommand: "yarn start",
5235
5244
  artifactsPaths: ["dist", ".next"],
5245
+ artifactsExcludePaths: [".next/cache/**/*"],
5236
5246
  }),
5237
5247
  },
5238
5248
  "node-static": {
@@ -125760,7 +125770,7 @@ module.exports = parse;
125760
125770
 
125761
125771
 
125762
125772
  var path = __nccwpck_require__(71017);
125763
- var which = __nccwpck_require__(63623);
125773
+ var which = __nccwpck_require__(73672);
125764
125774
  var LRU = __nccwpck_require__(64144);
125765
125775
 
125766
125776
  var commandCache = new LRU({ max: 50, maxAge: 30 * 1000 }); // Cache just for 30sec
@@ -126266,6 +126276,148 @@ function Entry (key, value, length, now, maxAge) {
126266
126276
  }
126267
126277
 
126268
126278
 
126279
+ /***/ }),
126280
+
126281
+ /***/ 73672:
126282
+ /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
126283
+
126284
+ module.exports = which
126285
+ which.sync = whichSync
126286
+
126287
+ var isWindows = process.platform === 'win32' ||
126288
+ process.env.OSTYPE === 'cygwin' ||
126289
+ process.env.OSTYPE === 'msys'
126290
+
126291
+ var path = __nccwpck_require__(71017)
126292
+ var COLON = isWindows ? ';' : ':'
126293
+ var isexe = __nccwpck_require__(15930)
126294
+
126295
+ function getNotFoundError (cmd) {
126296
+ var er = new Error('not found: ' + cmd)
126297
+ er.code = 'ENOENT'
126298
+
126299
+ return er
126300
+ }
126301
+
126302
+ function getPathInfo (cmd, opt) {
126303
+ var colon = opt.colon || COLON
126304
+ var pathEnv = opt.path || process.env.PATH || ''
126305
+ var pathExt = ['']
126306
+
126307
+ pathEnv = pathEnv.split(colon)
126308
+
126309
+ var pathExtExe = ''
126310
+ if (isWindows) {
126311
+ pathEnv.unshift(process.cwd())
126312
+ pathExtExe = (opt.pathExt || process.env.PATHEXT || '.EXE;.CMD;.BAT;.COM')
126313
+ pathExt = pathExtExe.split(colon)
126314
+
126315
+
126316
+ // Always test the cmd itself first. isexe will check to make sure
126317
+ // it's found in the pathExt set.
126318
+ if (cmd.indexOf('.') !== -1 && pathExt[0] !== '')
126319
+ pathExt.unshift('')
126320
+ }
126321
+
126322
+ // If it has a slash, then we don't bother searching the pathenv.
126323
+ // just check the file itself, and that's it.
126324
+ if (cmd.match(/\//) || isWindows && cmd.match(/\\/))
126325
+ pathEnv = ['']
126326
+
126327
+ return {
126328
+ env: pathEnv,
126329
+ ext: pathExt,
126330
+ extExe: pathExtExe
126331
+ }
126332
+ }
126333
+
126334
+ function which (cmd, opt, cb) {
126335
+ if (typeof opt === 'function') {
126336
+ cb = opt
126337
+ opt = {}
126338
+ }
126339
+
126340
+ var info = getPathInfo(cmd, opt)
126341
+ var pathEnv = info.env
126342
+ var pathExt = info.ext
126343
+ var pathExtExe = info.extExe
126344
+ var found = []
126345
+
126346
+ ;(function F (i, l) {
126347
+ if (i === l) {
126348
+ if (opt.all && found.length)
126349
+ return cb(null, found)
126350
+ else
126351
+ return cb(getNotFoundError(cmd))
126352
+ }
126353
+
126354
+ var pathPart = pathEnv[i]
126355
+ if (pathPart.charAt(0) === '"' && pathPart.slice(-1) === '"')
126356
+ pathPart = pathPart.slice(1, -1)
126357
+
126358
+ var p = path.join(pathPart, cmd)
126359
+ if (!pathPart && (/^\.[\\\/]/).test(cmd)) {
126360
+ p = cmd.slice(0, 2) + p
126361
+ }
126362
+ ;(function E (ii, ll) {
126363
+ if (ii === ll) return F(i + 1, l)
126364
+ var ext = pathExt[ii]
126365
+ isexe(p + ext, { pathExt: pathExtExe }, function (er, is) {
126366
+ if (!er && is) {
126367
+ if (opt.all)
126368
+ found.push(p + ext)
126369
+ else
126370
+ return cb(null, p + ext)
126371
+ }
126372
+ return E(ii + 1, ll)
126373
+ })
126374
+ })(0, pathExt.length)
126375
+ })(0, pathEnv.length)
126376
+ }
126377
+
126378
+ function whichSync (cmd, opt) {
126379
+ opt = opt || {}
126380
+
126381
+ var info = getPathInfo(cmd, opt)
126382
+ var pathEnv = info.env
126383
+ var pathExt = info.ext
126384
+ var pathExtExe = info.extExe
126385
+ var found = []
126386
+
126387
+ for (var i = 0, l = pathEnv.length; i < l; i ++) {
126388
+ var pathPart = pathEnv[i]
126389
+ if (pathPart.charAt(0) === '"' && pathPart.slice(-1) === '"')
126390
+ pathPart = pathPart.slice(1, -1)
126391
+
126392
+ var p = path.join(pathPart, cmd)
126393
+ if (!pathPart && /^\.[\\\/]/.test(cmd)) {
126394
+ p = cmd.slice(0, 2) + p
126395
+ }
126396
+ for (var j = 0, ll = pathExt.length; j < ll; j ++) {
126397
+ var cur = p + pathExt[j]
126398
+ var is
126399
+ try {
126400
+ is = isexe.sync(cur, { pathExt: pathExtExe })
126401
+ if (is) {
126402
+ if (opt.all)
126403
+ found.push(cur)
126404
+ else
126405
+ return cur
126406
+ }
126407
+ } catch (ex) {}
126408
+ }
126409
+ }
126410
+
126411
+ if (opt.all && found.length)
126412
+ return found
126413
+
126414
+ if (opt.nothrow)
126415
+ return null
126416
+
126417
+ throw getNotFoundError(cmd)
126418
+ }
126419
+
126420
+
126269
126421
  /***/ }),
126270
126422
 
126271
126423
  /***/ 4071:
@@ -127555,7 +127707,7 @@ module.exports = readShebang;
127555
127707
 
127556
127708
 
127557
127709
  const path = __nccwpck_require__(71017);
127558
- const which = __nccwpck_require__(63623);
127710
+ const which = __nccwpck_require__(87698);
127559
127711
  const pathKey = __nccwpck_require__(55003)();
127560
127712
 
127561
127713
  function resolveCommandAttempt(parsed, withoutPathExt) {
@@ -129807,6 +129959,148 @@ module.exports = function (str) {
129807
129959
  module.exports = /^#!.*/;
129808
129960
 
129809
129961
 
129962
+ /***/ }),
129963
+
129964
+ /***/ 87698:
129965
+ /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
129966
+
129967
+ module.exports = which
129968
+ which.sync = whichSync
129969
+
129970
+ var isWindows = process.platform === 'win32' ||
129971
+ process.env.OSTYPE === 'cygwin' ||
129972
+ process.env.OSTYPE === 'msys'
129973
+
129974
+ var path = __nccwpck_require__(71017)
129975
+ var COLON = isWindows ? ';' : ':'
129976
+ var isexe = __nccwpck_require__(15930)
129977
+
129978
+ function getNotFoundError (cmd) {
129979
+ var er = new Error('not found: ' + cmd)
129980
+ er.code = 'ENOENT'
129981
+
129982
+ return er
129983
+ }
129984
+
129985
+ function getPathInfo (cmd, opt) {
129986
+ var colon = opt.colon || COLON
129987
+ var pathEnv = opt.path || process.env.PATH || ''
129988
+ var pathExt = ['']
129989
+
129990
+ pathEnv = pathEnv.split(colon)
129991
+
129992
+ var pathExtExe = ''
129993
+ if (isWindows) {
129994
+ pathEnv.unshift(process.cwd())
129995
+ pathExtExe = (opt.pathExt || process.env.PATHEXT || '.EXE;.CMD;.BAT;.COM')
129996
+ pathExt = pathExtExe.split(colon)
129997
+
129998
+
129999
+ // Always test the cmd itself first. isexe will check to make sure
130000
+ // it's found in the pathExt set.
130001
+ if (cmd.indexOf('.') !== -1 && pathExt[0] !== '')
130002
+ pathExt.unshift('')
130003
+ }
130004
+
130005
+ // If it has a slash, then we don't bother searching the pathenv.
130006
+ // just check the file itself, and that's it.
130007
+ if (cmd.match(/\//) || isWindows && cmd.match(/\\/))
130008
+ pathEnv = ['']
130009
+
130010
+ return {
130011
+ env: pathEnv,
130012
+ ext: pathExt,
130013
+ extExe: pathExtExe
130014
+ }
130015
+ }
130016
+
130017
+ function which (cmd, opt, cb) {
130018
+ if (typeof opt === 'function') {
130019
+ cb = opt
130020
+ opt = {}
130021
+ }
130022
+
130023
+ var info = getPathInfo(cmd, opt)
130024
+ var pathEnv = info.env
130025
+ var pathExt = info.ext
130026
+ var pathExtExe = info.extExe
130027
+ var found = []
130028
+
130029
+ ;(function F (i, l) {
130030
+ if (i === l) {
130031
+ if (opt.all && found.length)
130032
+ return cb(null, found)
130033
+ else
130034
+ return cb(getNotFoundError(cmd))
130035
+ }
130036
+
130037
+ var pathPart = pathEnv[i]
130038
+ if (pathPart.charAt(0) === '"' && pathPart.slice(-1) === '"')
130039
+ pathPart = pathPart.slice(1, -1)
130040
+
130041
+ var p = path.join(pathPart, cmd)
130042
+ if (!pathPart && (/^\.[\\\/]/).test(cmd)) {
130043
+ p = cmd.slice(0, 2) + p
130044
+ }
130045
+ ;(function E (ii, ll) {
130046
+ if (ii === ll) return F(i + 1, l)
130047
+ var ext = pathExt[ii]
130048
+ isexe(p + ext, { pathExt: pathExtExe }, function (er, is) {
130049
+ if (!er && is) {
130050
+ if (opt.all)
130051
+ found.push(p + ext)
130052
+ else
130053
+ return cb(null, p + ext)
130054
+ }
130055
+ return E(ii + 1, ll)
130056
+ })
130057
+ })(0, pathExt.length)
130058
+ })(0, pathEnv.length)
130059
+ }
130060
+
130061
+ function whichSync (cmd, opt) {
130062
+ opt = opt || {}
130063
+
130064
+ var info = getPathInfo(cmd, opt)
130065
+ var pathEnv = info.env
130066
+ var pathExt = info.ext
130067
+ var pathExtExe = info.extExe
130068
+ var found = []
130069
+
130070
+ for (var i = 0, l = pathEnv.length; i < l; i ++) {
130071
+ var pathPart = pathEnv[i]
130072
+ if (pathPart.charAt(0) === '"' && pathPart.slice(-1) === '"')
130073
+ pathPart = pathPart.slice(1, -1)
130074
+
130075
+ var p = path.join(pathPart, cmd)
130076
+ if (!pathPart && /^\.[\\\/]/.test(cmd)) {
130077
+ p = cmd.slice(0, 2) + p
130078
+ }
130079
+ for (var j = 0, ll = pathExt.length; j < ll; j ++) {
130080
+ var cur = p + pathExt[j]
130081
+ var is
130082
+ try {
130083
+ is = isexe.sync(cur, { pathExt: pathExtExe })
130084
+ if (is) {
130085
+ if (opt.all)
130086
+ found.push(cur)
130087
+ else
130088
+ return cur
130089
+ }
130090
+ } catch (ex) {}
130091
+ }
130092
+ }
130093
+
130094
+ if (opt.all && found.length)
130095
+ return found
130096
+
130097
+ if (opt.nothrow)
130098
+ return null
130099
+
130100
+ throw getNotFoundError(cmd)
130101
+ }
130102
+
130103
+
129810
130104
  /***/ }),
129811
130105
 
129812
130106
  /***/ 60482:
@@ -141415,7 +141709,7 @@ module.exports = readShebang;
141415
141709
 
141416
141710
 
141417
141711
  const path = __nccwpck_require__(71017);
141418
- const which = __nccwpck_require__(28995);
141712
+ const which = __nccwpck_require__(63623);
141419
141713
  const getPathKey = __nccwpck_require__(20154);
141420
141714
 
141421
141715
  function resolveCommandAttempt(parsed, withoutPathExt) {
@@ -141466,138 +141760,6 @@ function resolveCommand(parsed) {
141466
141760
  module.exports = resolveCommand;
141467
141761
 
141468
141762
 
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
141763
  /***/ }),
141602
141764
 
141603
141765
  /***/ 95509:
@@ -293597,123 +293759,110 @@ module.exports.implForWrapper = function (wrapper) {
293597
293759
  /***/ 63623:
293598
293760
  /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
293599
293761
 
293600
- module.exports = which
293601
- which.sync = whichSync
293602
-
293603
- var isWindows = process.platform === 'win32' ||
293762
+ const isWindows = process.platform === 'win32' ||
293604
293763
  process.env.OSTYPE === 'cygwin' ||
293605
293764
  process.env.OSTYPE === 'msys'
293606
293765
 
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'
293766
+ const path = __nccwpck_require__(71017)
293767
+ const COLON = isWindows ? ';' : ':'
293768
+ const isexe = __nccwpck_require__(15930)
293614
293769
 
293615
- return er
293616
- }
293770
+ const getNotFoundError = (cmd) =>
293771
+ Object.assign(new Error(`not found: ${cmd}`), { code: 'ENOENT' })
293617
293772
 
293618
- function getPathInfo (cmd, opt) {
293619
- var colon = opt.colon || COLON
293620
- var pathEnv = opt.path || process.env.PATH || ''
293621
- var pathExt = ['']
293773
+ const getPathInfo = (cmd, opt) => {
293774
+ const colon = opt.colon || COLON
293622
293775
 
293623
- pathEnv = pathEnv.split(colon)
293776
+ // If it has a slash, then we don't bother searching the pathenv.
293777
+ // just check the file itself, and that's it.
293778
+ const pathEnv = cmd.match(/\//) || isWindows && cmd.match(/\\/) ? ['']
293779
+ : (
293780
+ [
293781
+ // windows always checks the cwd first
293782
+ ...(isWindows ? [process.cwd()] : []),
293783
+ ...(opt.path || process.env.PATH ||
293784
+ /* istanbul ignore next: very unusual */ '').split(colon),
293785
+ ]
293786
+ )
293787
+ const pathExtExe = isWindows
293788
+ ? opt.pathExt || process.env.PATHEXT || '.EXE;.CMD;.BAT;.COM'
293789
+ : ''
293790
+ const pathExt = isWindows ? pathExtExe.split(colon) : ['']
293624
293791
 
293625
- var pathExtExe = ''
293626
293792
  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
293793
  if (cmd.indexOf('.') !== -1 && pathExt[0] !== '')
293635
293794
  pathExt.unshift('')
293636
293795
  }
293637
293796
 
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
293797
  return {
293644
- env: pathEnv,
293645
- ext: pathExt,
293646
- extExe: pathExtExe
293798
+ pathEnv,
293799
+ pathExt,
293800
+ pathExtExe,
293647
293801
  }
293648
293802
  }
293649
293803
 
293650
- function which (cmd, opt, cb) {
293804
+ const which = (cmd, opt, cb) => {
293651
293805
  if (typeof opt === 'function') {
293652
293806
  cb = opt
293653
293807
  opt = {}
293654
293808
  }
293809
+ if (!opt)
293810
+ opt = {}
293655
293811
 
293656
- var info = getPathInfo(cmd, opt)
293657
- var pathEnv = info.env
293658
- var pathExt = info.ext
293659
- var pathExtExe = info.extExe
293660
- var found = []
293812
+ const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt)
293813
+ const found = []
293661
293814
 
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
- }
293815
+ const step = i => new Promise((resolve, reject) => {
293816
+ if (i === pathEnv.length)
293817
+ return opt.all && found.length ? resolve(found)
293818
+ : reject(getNotFoundError(cmd))
293669
293819
 
293670
- var pathPart = pathEnv[i]
293671
- if (pathPart.charAt(0) === '"' && pathPart.slice(-1) === '"')
293672
- pathPart = pathPart.slice(1, -1)
293820
+ const ppRaw = pathEnv[i]
293821
+ const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw
293673
293822
 
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)
293823
+ const pCmd = path.join(pathPart, cmd)
293824
+ const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd
293825
+ : pCmd
293826
+
293827
+ resolve(subStep(p, i, 0))
293828
+ })
293829
+
293830
+ const subStep = (p, i, ii) => new Promise((resolve, reject) => {
293831
+ if (ii === pathExt.length)
293832
+ return resolve(step(i + 1))
293833
+ const ext = pathExt[ii]
293834
+ isexe(p + ext, { pathExt: pathExtExe }, (er, is) => {
293835
+ if (!er && is) {
293836
+ if (opt.all)
293837
+ found.push(p + ext)
293838
+ else
293839
+ return resolve(p + ext)
293840
+ }
293841
+ return resolve(subStep(p, i, ii + 1))
293842
+ })
293843
+ })
293844
+
293845
+ return cb ? step(0).then(res => cb(null, res), cb) : step(0)
293692
293846
  }
293693
293847
 
293694
- function whichSync (cmd, opt) {
293848
+ const whichSync = (cmd, opt) => {
293695
293849
  opt = opt || {}
293696
293850
 
293697
- var info = getPathInfo(cmd, opt)
293698
- var pathEnv = info.env
293699
- var pathExt = info.ext
293700
- var pathExtExe = info.extExe
293701
- var found = []
293851
+ const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt)
293852
+ const found = []
293702
293853
 
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)
293854
+ for (let i = 0; i < pathEnv.length; i ++) {
293855
+ const ppRaw = pathEnv[i]
293856
+ const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw
293707
293857
 
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
293858
+ const pCmd = path.join(pathPart, cmd)
293859
+ const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd
293860
+ : pCmd
293861
+
293862
+ for (let j = 0; j < pathExt.length; j ++) {
293863
+ const cur = p + pathExt[j]
293715
293864
  try {
293716
- is = isexe.sync(cur, { pathExt: pathExtExe })
293865
+ const is = isexe.sync(cur, { pathExt: pathExtExe })
293717
293866
  if (is) {
293718
293867
  if (opt.all)
293719
293868
  found.push(cur)
@@ -293733,6 +293882,9 @@ function whichSync (cmd, opt) {
293733
293882
  throw getNotFoundError(cmd)
293734
293883
  }
293735
293884
 
293885
+ module.exports = which
293886
+ which.sync = whichSync
293887
+
293736
293888
 
293737
293889
  /***/ }),
293738
293890