jsir 2.0.8 → 2.1.1
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/cmd/oaa.js +183 -143
- package/package.json +1 -1
- package/util.js +2 -2
package/cmd/oaa.js
CHANGED
|
@@ -6,7 +6,7 @@ const {
|
|
|
6
6
|
info, warn, error, arrayDataFile, infoStr, warnStr, errorStack,
|
|
7
7
|
getInfo, ei, pad, msgStr, getType,
|
|
8
8
|
errorTag, isArgsMatch, draftQuery, setConfig,
|
|
9
|
-
$log, $draft, getTextComments
|
|
9
|
+
$log, $draft, getTextComments, getOr, importG
|
|
10
10
|
} = $lib;
|
|
11
11
|
const _args = process.argv.slice(2).map(trim);
|
|
12
12
|
const evalCode = require('../evalCode')
|
|
@@ -15,6 +15,7 @@ const _chokidar = require('chokidar');
|
|
|
15
15
|
const setting = require('../setting')
|
|
16
16
|
const _fs = require('fs')
|
|
17
17
|
const readline = require("readline");
|
|
18
|
+
const {requireG} = require("../util");
|
|
18
19
|
|
|
19
20
|
const _workspaceConfigFile = 'workspace.json';
|
|
20
21
|
const _libDataDir = getLibDataDir()
|
|
@@ -40,12 +41,14 @@ let _noAppendNextLine = true
|
|
|
40
41
|
|
|
41
42
|
const _onGetMap = {}
|
|
42
43
|
const _data = {}
|
|
44
|
+
const _tempTime = 60 * 1000
|
|
43
45
|
const _dealOnGet = (key) => {
|
|
44
46
|
if (_noAppendNextLine || !_onGetMap[key]) {
|
|
45
47
|
return _data[key]
|
|
46
48
|
}
|
|
47
49
|
let item = _onGetMap[key]
|
|
48
50
|
if (Date.now() <= item.startTime) {
|
|
51
|
+
item.startTime = Date.now() + _tempTime
|
|
49
52
|
return _data[key]
|
|
50
53
|
}
|
|
51
54
|
let flag = _onGetMap[key].fn()
|
|
@@ -53,21 +56,21 @@ const _dealOnGet = (key) => {
|
|
|
53
56
|
return new Promise(async (resolve, reject) => {
|
|
54
57
|
try {
|
|
55
58
|
await flag
|
|
56
|
-
item.startTime = Date.now() +
|
|
59
|
+
item.startTime = Date.now() + _tempTime
|
|
57
60
|
resolve(_data[key])
|
|
58
61
|
} catch (e) {
|
|
59
62
|
reject(e)
|
|
60
63
|
}
|
|
61
64
|
})
|
|
62
65
|
} else {
|
|
63
|
-
item.startTime = Date.now() +
|
|
66
|
+
item.startTime = Date.now() + _tempTime
|
|
64
67
|
return _data[key]
|
|
65
68
|
}
|
|
66
69
|
}
|
|
67
70
|
const $data = {
|
|
68
71
|
get: (key, defaultVal) => {
|
|
69
72
|
if (!vl(_data[key])) {
|
|
70
|
-
if (
|
|
73
|
+
if (defaultVal !== undefined) {
|
|
71
74
|
return defaultVal
|
|
72
75
|
} else {
|
|
73
76
|
return _data[key]
|
|
@@ -77,7 +80,7 @@ const $data = {
|
|
|
77
80
|
},
|
|
78
81
|
gos: (key, defaultVal) => {
|
|
79
82
|
if (!vl(_data[key])) {
|
|
80
|
-
if (
|
|
83
|
+
if (defaultVal !== undefined) {
|
|
81
84
|
_data[key] = defaultVal
|
|
82
85
|
return defaultVal
|
|
83
86
|
} else {
|
|
@@ -90,7 +93,7 @@ const $data = {
|
|
|
90
93
|
if (onGet) {
|
|
91
94
|
_onGetMap[key] = {
|
|
92
95
|
fn: onGet,
|
|
93
|
-
startTime: Date.now() +
|
|
96
|
+
startTime: Date.now() + _tempTime
|
|
94
97
|
}
|
|
95
98
|
}
|
|
96
99
|
return _data[key] = val
|
|
@@ -295,7 +298,7 @@ function initRl(callback, preStr, hidden) {
|
|
|
295
298
|
if (promptStr !== '') {
|
|
296
299
|
promptStr = (preStr
|
|
297
300
|
|| ((callback && callback !== wrapperInput) ? "-> ":"")
|
|
298
|
-
|| [Object.values(global.$tips).map(
|
|
301
|
+
|| [Object.values(global.$tips).map(trim).filter(i => i).map(i => i.replace(/,/g, '-')).join(','), $defaultSpace].filter(i => i).join(':') + `> `)
|
|
299
302
|
promptStr = infoStr(promptStr)
|
|
300
303
|
}
|
|
301
304
|
if (hidden) {
|
|
@@ -339,7 +342,7 @@ function _nextLine(callback, preStr, hidden, resolve, end) {
|
|
|
339
342
|
} else {
|
|
340
343
|
inputStr = line
|
|
341
344
|
if (/^\s+$/.test(textLine) && (!callback || wrapperInput === callback)) {
|
|
342
|
-
|
|
345
|
+
process.stdout.write('\033[2J\033[H');
|
|
343
346
|
listCmd();
|
|
344
347
|
}
|
|
345
348
|
}
|
|
@@ -573,12 +576,7 @@ async function _wrapperInput(str) {
|
|
|
573
576
|
await evalText(text)
|
|
574
577
|
}
|
|
575
578
|
} else if (str.match(/^\./)) {
|
|
576
|
-
|
|
577
|
-
if (items.length > 0) {
|
|
578
|
-
await dealKeyword(items[0], items.slice(1))
|
|
579
|
-
} else {
|
|
580
|
-
help()
|
|
581
|
-
}
|
|
579
|
+
await dealKeyword(enrichArgs(str))
|
|
582
580
|
} else if (!str.split(/\s+/)[0].match(/^\d+$/)) {
|
|
583
581
|
_cmdMap = arrayToCmdMap(filterCmd(str))
|
|
584
582
|
listCmd()
|
|
@@ -724,6 +722,13 @@ const keywordDef = {
|
|
|
724
722
|
},
|
|
725
723
|
short: 'h'
|
|
726
724
|
},
|
|
725
|
+
version: {
|
|
726
|
+
comment: '查看版本',
|
|
727
|
+
exeFn: (args) => {
|
|
728
|
+
console.log(require("../package.json").version)
|
|
729
|
+
},
|
|
730
|
+
short: 'v'
|
|
731
|
+
},
|
|
727
732
|
list: {
|
|
728
733
|
comment: '查看文件列表',
|
|
729
734
|
exeFn: (args) => {
|
|
@@ -879,23 +884,40 @@ const keywordDef = {
|
|
|
879
884
|
},
|
|
880
885
|
short: 'c'
|
|
881
886
|
},
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
887
|
+
deps: {
|
|
888
|
+
comment: '查看文件依赖',
|
|
889
|
+
exeFn: (args) => {
|
|
890
|
+
let uniqueName = _cmdMap[args[0]]
|
|
891
|
+
if (!uniqueName) {
|
|
892
|
+
warn("no items")
|
|
893
|
+
} else {
|
|
894
|
+
let cmds = getScriptRequires(uniqueName);
|
|
895
|
+
_cmdMap = arrayToCmdMap(cmds)
|
|
896
|
+
listCmd()
|
|
897
|
+
|
|
898
|
+
for (let un of cmds) {
|
|
899
|
+
let path = getFullPath(un);
|
|
900
|
+
let text = removeComment(String(_fs.readFileSync(path)))
|
|
901
|
+
regEach(text, /[^$]require\s*\(([^()]+)\)/g, r=> {
|
|
902
|
+
if (r[1]) {
|
|
903
|
+
try {
|
|
904
|
+
requireG(evalVal(r[1]))
|
|
905
|
+
} catch (e) {}
|
|
906
|
+
}
|
|
907
|
+
});
|
|
908
|
+
regEach(text, /\$import\s*\(([^()]+)\)/g, r=> {
|
|
909
|
+
if (r[1]) {
|
|
910
|
+
importG(evalVal(r[1]))
|
|
911
|
+
}
|
|
912
|
+
});
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
},
|
|
916
|
+
args: {
|
|
917
|
+
fileIndex: '文件下标'
|
|
918
|
+
},
|
|
919
|
+
short: 'd'
|
|
920
|
+
},
|
|
899
921
|
file: {
|
|
900
922
|
comment: '工作文件模式',
|
|
901
923
|
exeFn: async (args) => {
|
|
@@ -1036,7 +1058,32 @@ const keywordDef = {
|
|
|
1036
1058
|
}
|
|
1037
1059
|
}
|
|
1038
1060
|
|
|
1039
|
-
async function dealKeyword(
|
|
1061
|
+
async function dealKeyword(items) {
|
|
1062
|
+
let keyword;
|
|
1063
|
+
let args = []
|
|
1064
|
+
for (let item of items) {
|
|
1065
|
+
if (!item.endsWith(" ") && item.startsWith(".")) {
|
|
1066
|
+
if (keyword) {
|
|
1067
|
+
await _dealKeyword(keyword, args)
|
|
1068
|
+
}
|
|
1069
|
+
keyword = trim(item);
|
|
1070
|
+
args = []
|
|
1071
|
+
continue
|
|
1072
|
+
}
|
|
1073
|
+
if (keyword) {
|
|
1074
|
+
args.push(trim(item))
|
|
1075
|
+
}
|
|
1076
|
+
}
|
|
1077
|
+
if (keyword) {
|
|
1078
|
+
await _dealKeyword(keyword, args)
|
|
1079
|
+
}
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1082
|
+
async function _dealKeyword(keyword, args) {
|
|
1083
|
+
if (keyword === '.') {
|
|
1084
|
+
keyword = '.help'
|
|
1085
|
+
}
|
|
1086
|
+
keyword = keyword.substring(1)
|
|
1040
1087
|
let unMatched = true;
|
|
1041
1088
|
for (let key of Object.keys(keywordDef)) {
|
|
1042
1089
|
let item = keywordDef[key]
|
|
@@ -1048,51 +1095,80 @@ async function dealKeyword(keyword, args) {
|
|
|
1048
1095
|
}
|
|
1049
1096
|
}
|
|
1050
1097
|
if (unMatched) {
|
|
1051
|
-
warn(
|
|
1098
|
+
warn(`unknown keyword: ${keyword}`)
|
|
1052
1099
|
}
|
|
1053
1100
|
}
|
|
1054
1101
|
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1102
|
+
function removeComment(text) {
|
|
1103
|
+
let result = []
|
|
1104
|
+
let start = false
|
|
1105
|
+
for (let line of text.split('\n')) {
|
|
1106
|
+
if (trim(line).startsWith("/*")) {
|
|
1107
|
+
start = true;
|
|
1108
|
+
continue
|
|
1109
|
+
}
|
|
1110
|
+
if (trim(line).endsWith("*/")) {
|
|
1111
|
+
start = false;
|
|
1112
|
+
continue
|
|
1113
|
+
}
|
|
1114
|
+
if (trim(line).startsWith("//")) {
|
|
1115
|
+
continue
|
|
1116
|
+
}
|
|
1117
|
+
if (start) {
|
|
1118
|
+
continue
|
|
1119
|
+
}
|
|
1120
|
+
result.push(line)
|
|
1121
|
+
}
|
|
1122
|
+
return result.join("\n")
|
|
1123
|
+
}
|
|
1124
|
+
|
|
1125
|
+
function _getScriptRequires(uniqueName, cmds, links) {
|
|
1126
|
+
let path = getFullPath(uniqueName);
|
|
1127
|
+
let text = removeComment(String(_fs.readFileSync(path)))
|
|
1128
|
+
let temp = []
|
|
1129
|
+
regEach(text, /\$require\s*\(([^()]+)\)/g, r=> {
|
|
1130
|
+
if (r[1]) {
|
|
1131
|
+
let matchStr
|
|
1132
|
+
try {
|
|
1133
|
+
matchStr = evalVal(r[1])
|
|
1134
|
+
} catch (e) {}
|
|
1135
|
+
if (matchStr) {
|
|
1136
|
+
temp.push(filterRequire(parseUniqueName(uniqueName)[0], matchStr))
|
|
1137
|
+
}
|
|
1138
|
+
}
|
|
1139
|
+
});
|
|
1140
|
+
regEach(text, /\$requires\s*\(([^()]+)\)/g, r=> {
|
|
1141
|
+
if (r[1]) {
|
|
1142
|
+
for (const item of r[1].split(/,/)) {
|
|
1143
|
+
let matchStr
|
|
1144
|
+
try {
|
|
1145
|
+
matchStr = evalVal(item)
|
|
1146
|
+
} catch (e) {}
|
|
1147
|
+
if (matchStr) {
|
|
1148
|
+
temp.push(filterRequire(parseUniqueName(uniqueName)[0], matchStr))
|
|
1149
|
+
}
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
1152
|
+
});
|
|
1153
|
+
temp = [...new Set(temp)]
|
|
1154
|
+
temp.forEach(i => {
|
|
1155
|
+
if (links.indexOf(i) !== -1) {
|
|
1156
|
+
let items = [...links, i];
|
|
1157
|
+
let errorStr = items.map(item => item === i ? warnStr(item):item).join("->")
|
|
1158
|
+
throw `circle deps: ${errorStr}`
|
|
1159
|
+
}
|
|
1160
|
+
})
|
|
1161
|
+
cmds.push(...temp)
|
|
1162
|
+
for (let un of temp) {
|
|
1163
|
+
_getScriptRequires(un, cmds, [...links, un])
|
|
1164
|
+
}
|
|
1165
|
+
}
|
|
1166
|
+
|
|
1167
|
+
function getScriptRequires(uniqueName) {
|
|
1168
|
+
let cmds = [];
|
|
1169
|
+
_getScriptRequires(uniqueName, cmds, [uniqueName]);
|
|
1170
|
+
return [...new Set(cmds)]
|
|
1171
|
+
}
|
|
1096
1172
|
|
|
1097
1173
|
function getComments(i, cmdName, text, cols = [], col) {
|
|
1098
1174
|
let docLines = [infoStr(getCmdMd5Key(parseUniqueName(cmdName)[1])) + " - " + infoStr(i)]
|
|
@@ -1429,9 +1505,11 @@ function getArgDef(text) {
|
|
|
1429
1505
|
}
|
|
1430
1506
|
|
|
1431
1507
|
function setTips(key, value, onRm) {
|
|
1432
|
-
global.$tips[
|
|
1508
|
+
let vals = getOr(global.$tips, key, []);
|
|
1509
|
+
vals.push(value)
|
|
1510
|
+
global.$tips[key] = [...new Set(vals)]
|
|
1433
1511
|
if (onRm) {
|
|
1434
|
-
_tipsOnRm[
|
|
1512
|
+
getOr(_tipsOnRm, key, []).push(onRm)
|
|
1435
1513
|
}
|
|
1436
1514
|
}
|
|
1437
1515
|
|
|
@@ -1453,14 +1531,16 @@ function delTips(...keys) {
|
|
|
1453
1531
|
}
|
|
1454
1532
|
|
|
1455
1533
|
function tipsOnRmCallback(key) {
|
|
1456
|
-
let
|
|
1534
|
+
let callbacks = _tipsOnRm[key]
|
|
1457
1535
|
delete _tipsOnRm[key]
|
|
1458
|
-
if (
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1536
|
+
if (callbacks && callbacks.length > 0) {
|
|
1537
|
+
for (let callback of callbacks) {
|
|
1538
|
+
try {
|
|
1539
|
+
callback()
|
|
1540
|
+
} catch (e) {
|
|
1541
|
+
$log(errorStack(e))
|
|
1542
|
+
error(`[${key}] OnRmCallback: ${String(e)}`)
|
|
1543
|
+
}
|
|
1464
1544
|
}
|
|
1465
1545
|
}
|
|
1466
1546
|
}
|
|
@@ -1469,13 +1549,11 @@ function getCmdMd5Key(str) {
|
|
|
1469
1549
|
return '0x' + md5(str).substr(0, 8);
|
|
1470
1550
|
}
|
|
1471
1551
|
|
|
1472
|
-
|
|
1473
|
-
cmdMatchStr
|
|
1474
|
-
|
|
1475
|
-
if (cmdMatchStr.startsWith("*")) {
|
|
1476
|
-
nullable = true;
|
|
1477
|
-
cmdMatchStr = trim(cmdMatchStr.substr(1));
|
|
1552
|
+
function filterRequire(currSpace, cmdMatchStr) {
|
|
1553
|
+
if (typeof cmdMatchStr === 'number') {
|
|
1554
|
+
cmdMatchStr = '0x' + pad(8, BigNumber(cmdMatchStr).toString(16), '0');
|
|
1478
1555
|
}
|
|
1556
|
+
cmdMatchStr = trim(cmdMatchStr);
|
|
1479
1557
|
|
|
1480
1558
|
let cmds;
|
|
1481
1559
|
let uName = toUniqueName(cmdMatchStr, currSpace)
|
|
@@ -1494,30 +1572,22 @@ async function _requireSource(currSpace, cmdMatchStr, printLog = false) {
|
|
|
1494
1572
|
cmds = cmds.filter(cmd => parseUniqueName(cmd)[0] === (appointSpace || currSpace))
|
|
1495
1573
|
}
|
|
1496
1574
|
}
|
|
1497
|
-
if (cmds.length
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
}
|
|
1501
|
-
throw `none unique match: ${cmdMatchStr}`
|
|
1575
|
+
if (cmds.length > 1) {
|
|
1576
|
+
throw `multiple match: ${cmdMatchStr}`
|
|
1577
|
+
} else if (cmds.length < 1) {
|
|
1578
|
+
throw `none match: ${cmdMatchStr}`
|
|
1502
1579
|
}
|
|
1580
|
+
return cmds[0];
|
|
1581
|
+
}
|
|
1503
1582
|
|
|
1583
|
+
async function _requireSource(currSpace, cmdMatchStr) {
|
|
1504
1584
|
let result
|
|
1505
|
-
let uniqueName =
|
|
1585
|
+
let uniqueName = filterRequire(currSpace, cmdMatchStr);
|
|
1506
1586
|
let path = getFullPath(uniqueName)
|
|
1507
1587
|
let text = String(_fs.readFileSync(path))
|
|
1508
1588
|
let pair = parseUniqueName(uniqueName)
|
|
1509
1589
|
if (pair[1].startsWith('i ')) {
|
|
1510
|
-
|
|
1511
|
-
result = await evalText(text, uniqueName)
|
|
1512
|
-
} catch (e) {
|
|
1513
|
-
if (nullable) {
|
|
1514
|
-
warn(`require [${cmdMatchStr}] failed`)
|
|
1515
|
-
$log(errorStack(e))
|
|
1516
|
-
return null;
|
|
1517
|
-
} else {
|
|
1518
|
-
throw e
|
|
1519
|
-
}
|
|
1520
|
-
}
|
|
1590
|
+
result = await evalText(text, uniqueName)
|
|
1521
1591
|
} else if (pair[1].startsWith('e ')) {
|
|
1522
1592
|
result = async (argsStr) => {
|
|
1523
1593
|
return await runCmd(trim(argsStr), uniqueName, text)
|
|
@@ -1526,37 +1596,24 @@ async function _requireSource(currSpace, cmdMatchStr, printLog = false) {
|
|
|
1526
1596
|
result = text;
|
|
1527
1597
|
}
|
|
1528
1598
|
if (!vl(result)) {
|
|
1529
|
-
if (nullable) {
|
|
1530
|
-
return null;
|
|
1531
|
-
}
|
|
1532
1599
|
throw `invalid result: ${cmdMatchStr}`
|
|
1533
1600
|
}
|
|
1534
1601
|
if (getType(result) === 'Function' || getType(result) === 'AsyncFunction') {
|
|
1535
1602
|
let tmp = result;
|
|
1536
1603
|
result = (...args) => {
|
|
1537
1604
|
let resp
|
|
1538
|
-
let startTime = Date.now();
|
|
1539
|
-
let pl = () => {
|
|
1540
|
-
if (printLog) {
|
|
1541
|
-
info(`${uniqueName} finished in ${Date.now() - startTime}ms`)
|
|
1542
|
-
}
|
|
1543
|
-
}
|
|
1544
1605
|
try {
|
|
1545
1606
|
resp = tmp(...args)
|
|
1546
1607
|
if (getType(resp) === 'Promise') {
|
|
1547
1608
|
return resp.then(result => {
|
|
1548
|
-
pl();
|
|
1549
1609
|
return Promise.resolve(result);
|
|
1550
1610
|
}).catch(e => {
|
|
1551
|
-
pl();
|
|
1552
1611
|
return Promise.reject(errorTag(e, uniqueName))
|
|
1553
1612
|
})
|
|
1554
1613
|
} else {
|
|
1555
|
-
pl();
|
|
1556
1614
|
return resp;
|
|
1557
1615
|
}
|
|
1558
1616
|
} catch (e) {
|
|
1559
|
-
pl();
|
|
1560
1617
|
throw errorTag(e, uniqueName);
|
|
1561
1618
|
}
|
|
1562
1619
|
}
|
|
@@ -1564,27 +1621,6 @@ async function _requireSource(currSpace, cmdMatchStr, printLog = false) {
|
|
|
1564
1621
|
return result
|
|
1565
1622
|
}
|
|
1566
1623
|
|
|
1567
|
-
async function _requireSources(currSpace, ...matchItems) {
|
|
1568
|
-
let result = []
|
|
1569
|
-
for (let i = 0; i < matchItems.length; i++) {
|
|
1570
|
-
let curr = matchItems[i]
|
|
1571
|
-
let next = matchItems[i + 1]
|
|
1572
|
-
if (typeof curr === 'number') {
|
|
1573
|
-
curr = '0x' + pad(8, BigNumber(curr).toString(16), '0');
|
|
1574
|
-
}
|
|
1575
|
-
if (typeof next === 'number') {
|
|
1576
|
-
next = '0x' + pad(8, BigNumber(next).toString(16), '0');
|
|
1577
|
-
}
|
|
1578
|
-
if (typeof curr === 'string' && typeof next !== "string") {
|
|
1579
|
-
result.push(await _requireSource(currSpace, curr, next))
|
|
1580
|
-
i++
|
|
1581
|
-
} else if (typeof curr === 'string') {
|
|
1582
|
-
result.push(await _requireSource(currSpace, curr))
|
|
1583
|
-
}
|
|
1584
|
-
}
|
|
1585
|
-
return result
|
|
1586
|
-
}
|
|
1587
|
-
|
|
1588
1624
|
async function evalText($text = '', $cmdName = '', $args = []) {
|
|
1589
1625
|
let currSpace;
|
|
1590
1626
|
if ($cmdName) {
|
|
@@ -1594,10 +1630,14 @@ async function evalText($text = '', $cmdName = '', $args = []) {
|
|
|
1594
1630
|
currSpace = $defaultSpace
|
|
1595
1631
|
}
|
|
1596
1632
|
let $requires = async (...matchItems) => {
|
|
1597
|
-
|
|
1633
|
+
let result = []
|
|
1634
|
+
for (let i = 0; i < matchItems.length; i++) {
|
|
1635
|
+
result.push(await _requireSource(currSpace, matchItems[i]))
|
|
1636
|
+
}
|
|
1637
|
+
return result
|
|
1598
1638
|
}
|
|
1599
|
-
let $require = async (matchItem
|
|
1600
|
-
return
|
|
1639
|
+
let $require = async (matchItem) => {
|
|
1640
|
+
return await _requireSource(currSpace, matchItem)
|
|
1601
1641
|
}
|
|
1602
1642
|
try {
|
|
1603
1643
|
return await evalCode($text, $cmdName, $args,
|
package/package.json
CHANGED
package/util.js
CHANGED
|
@@ -425,7 +425,7 @@ function getConfig(key, defaultVal) {
|
|
|
425
425
|
if (typeof defaultVal === "string") {
|
|
426
426
|
defaultVal = trim(defaultVal)
|
|
427
427
|
}
|
|
428
|
-
if (!vl(config[key]) &&
|
|
428
|
+
if (!vl(config[key]) && defaultVal !== undefined) {
|
|
429
429
|
return defaultVal
|
|
430
430
|
}
|
|
431
431
|
let val = config[key]
|
|
@@ -735,7 +735,7 @@ function _linuxAskAndKill(rl, keys){
|
|
|
735
735
|
}
|
|
736
736
|
|
|
737
737
|
function trim(obj) {
|
|
738
|
-
return obj ? String(obj).trim():""
|
|
738
|
+
return vl(obj) ? String(obj).trim():""
|
|
739
739
|
}
|
|
740
740
|
|
|
741
741
|
function getLibDataDir() {
|