@cabloy/cli 3.1.5 → 3.1.7

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.
Files changed (2) hide show
  1. package/dist/index.js +13 -6
  2. package/package.json +5 -5
package/dist/index.js CHANGED
@@ -12,7 +12,7 @@ import { globby } from 'globby';
12
12
  import path from 'node:path';
13
13
  import * as ModuleInfo from '@cabloy/module-info';
14
14
  import { ProcessHelper } from '@cabloy/process-helper';
15
- import { combineResourceName, catchError, evaluate } from '@cabloy/utils';
15
+ import { combineResourceName, catchError, isNil, evaluate } from '@cabloy/utils';
16
16
  import TableClass from 'cli-table3';
17
17
  import gogocode from 'gogocode';
18
18
  import { pathToFileURL } from 'node:url';
@@ -1432,7 +1432,7 @@ class CliCommand extends BaseCommand {
1432
1432
  const varsWant = [];
1433
1433
  for (const key in group.questions) {
1434
1434
  const value = argv[key];
1435
- if (value !== undefined) continue;
1435
+ if (!isNil(value)) continue;
1436
1436
  const question = group.questions[key];
1437
1437
  const varWant = this._prepareQuestion({
1438
1438
  group,
@@ -1464,13 +1464,20 @@ class CliCommand extends BaseCommand {
1464
1464
  const expression = question[propName] && question[propName].expression;
1465
1465
  if (!expression) return null;
1466
1466
  return function (value) {
1467
- return evaluate(expression, {
1467
+ const res = evaluate(expression, {
1468
1468
  value,
1469
1469
  group,
1470
1470
  question,
1471
1471
  key,
1472
- context
1472
+ context,
1473
+ arg0: context.argv._[0] ?? null,
1474
+ arg1: context.argv._[1] ?? null,
1475
+ arg2: context.argv._[2] ?? null,
1476
+ arg3: context.argv._[3] ?? null,
1477
+ arg4: context.argv._[4] ?? null,
1478
+ arg5: context.argv._[5] ?? null
1473
1479
  });
1480
+ return res === null ? undefined : res;
1474
1481
  };
1475
1482
  }
1476
1483
  _prepareQuestion({
@@ -1504,7 +1511,7 @@ class CliCommand extends BaseCommand {
1504
1511
  let initial = varWant.initial;
1505
1512
  if (initial && is.function(initial)) {
1506
1513
  initial = initial();
1507
- if (initial !== undefined) {
1514
+ if (!isNil(initial)) {
1508
1515
  argv[key] = initial;
1509
1516
  return null;
1510
1517
  }
@@ -1553,7 +1560,7 @@ class CliCommand extends BaseCommand {
1553
1560
  if (options) {
1554
1561
  for (const key in options) {
1555
1562
  const option = options[key];
1556
- if (option.alias && argv[key] === undefined) {
1563
+ if (option.alias && isNil(argv[key])) {
1557
1564
  argv[key] = argv[option.alias];
1558
1565
  }
1559
1566
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cabloy/cli",
3
- "version": "3.1.5",
3
+ "version": "3.1.7",
4
4
  "gitHead": "a79189b882c17af5911573896a781bbb0046d37d",
5
5
  "description": "@cabloy/cli",
6
6
  "keywords": [
@@ -29,7 +29,7 @@
29
29
  "dependencies": {
30
30
  "@babel/parser": "^7.29.2",
31
31
  "@cabloy/module-info": "^2.0.0",
32
- "@cabloy/word-utils": "^2.1.7",
32
+ "@cabloy/word-utils": "^2.1.8",
33
33
  "@npmcli/config": "^10.8.1",
34
34
  "@zhennann/common-bin": "^4.0.1",
35
35
  "@zhennann/ejs": "^3.0.1",
@@ -46,9 +46,9 @@
46
46
  "semver": "^7.7.4",
47
47
  "tmp": "^0.2.5",
48
48
  "urllib": "^3.27.3",
49
- "@cabloy/module-glob": "^5.3.4",
50
- "@cabloy/utils": "^2.1.4",
51
- "@cabloy/process-helper": "^3.1.4"
49
+ "@cabloy/module-glob": "^5.3.5",
50
+ "@cabloy/process-helper": "^3.1.4",
51
+ "@cabloy/utils": "^2.1.5"
52
52
  },
53
53
  "scripts": {
54
54
  "clean": "rimraf dist tsconfig.tsbuildinfo",