@cabloy/cli 3.1.6 → 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.
- package/dist/index.js +13 -6
- package/package.json +1 -1
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
|
|
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
|
-
|
|
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
|
|
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]
|
|
1563
|
+
if (option.alias && isNil(argv[key])) {
|
|
1557
1564
|
argv[key] = argv[option.alias];
|
|
1558
1565
|
}
|
|
1559
1566
|
}
|