jsir 2.0.8 → 2.0.9
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 +185 -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,42 @@ 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
|
+
error(e)
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
});
|
|
910
|
+
regEach(text, /\$import\s*\(([^()]+)\)/g, r=> {
|
|
911
|
+
if (r[1]) {
|
|
912
|
+
importG(evalVal(r[1])).catch(e => error(e))
|
|
913
|
+
}
|
|
914
|
+
});
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
},
|
|
918
|
+
args: {
|
|
919
|
+
fileIndex: '文件下标'
|
|
920
|
+
},
|
|
921
|
+
short: 'd'
|
|
922
|
+
},
|
|
899
923
|
file: {
|
|
900
924
|
comment: '工作文件模式',
|
|
901
925
|
exeFn: async (args) => {
|
|
@@ -1036,7 +1060,32 @@ const keywordDef = {
|
|
|
1036
1060
|
}
|
|
1037
1061
|
}
|
|
1038
1062
|
|
|
1039
|
-
async function dealKeyword(
|
|
1063
|
+
async function dealKeyword(items) {
|
|
1064
|
+
let keyword;
|
|
1065
|
+
let args = []
|
|
1066
|
+
for (let item of items) {
|
|
1067
|
+
if (!item.endsWith(" ") && item.startsWith(".")) {
|
|
1068
|
+
if (keyword) {
|
|
1069
|
+
await _dealKeyword(keyword, args)
|
|
1070
|
+
}
|
|
1071
|
+
keyword = trim(item);
|
|
1072
|
+
args = []
|
|
1073
|
+
continue
|
|
1074
|
+
}
|
|
1075
|
+
if (keyword) {
|
|
1076
|
+
args.push(trim(item))
|
|
1077
|
+
}
|
|
1078
|
+
}
|
|
1079
|
+
if (keyword) {
|
|
1080
|
+
await _dealKeyword(keyword, args)
|
|
1081
|
+
}
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1084
|
+
async function _dealKeyword(keyword, args) {
|
|
1085
|
+
if (keyword === '.') {
|
|
1086
|
+
keyword = '.help'
|
|
1087
|
+
}
|
|
1088
|
+
keyword = keyword.substring(1)
|
|
1040
1089
|
let unMatched = true;
|
|
1041
1090
|
for (let key of Object.keys(keywordDef)) {
|
|
1042
1091
|
let item = keywordDef[key]
|
|
@@ -1048,51 +1097,80 @@ async function dealKeyword(keyword, args) {
|
|
|
1048
1097
|
}
|
|
1049
1098
|
}
|
|
1050
1099
|
if (unMatched) {
|
|
1051
|
-
warn(
|
|
1100
|
+
warn(`unknown keyword: ${keyword}`)
|
|
1052
1101
|
}
|
|
1053
1102
|
}
|
|
1054
1103
|
|
|
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
|
-
|
|
1104
|
+
function removeComment(text) {
|
|
1105
|
+
let result = []
|
|
1106
|
+
let start = false
|
|
1107
|
+
for (let line of text.split('\n')) {
|
|
1108
|
+
if (trim(line).startsWith("/*")) {
|
|
1109
|
+
start = true;
|
|
1110
|
+
continue
|
|
1111
|
+
}
|
|
1112
|
+
if (trim(line).endsWith("*/")) {
|
|
1113
|
+
start = false;
|
|
1114
|
+
continue
|
|
1115
|
+
}
|
|
1116
|
+
if (trim(line).startsWith("//")) {
|
|
1117
|
+
continue
|
|
1118
|
+
}
|
|
1119
|
+
if (start) {
|
|
1120
|
+
continue
|
|
1121
|
+
}
|
|
1122
|
+
result.push(line)
|
|
1123
|
+
}
|
|
1124
|
+
return result.join("\n")
|
|
1125
|
+
}
|
|
1126
|
+
|
|
1127
|
+
function _getScriptRequires(uniqueName, cmds, links) {
|
|
1128
|
+
let path = getFullPath(uniqueName);
|
|
1129
|
+
let text = removeComment(String(_fs.readFileSync(path)))
|
|
1130
|
+
let temp = []
|
|
1131
|
+
regEach(text, /\$require\s*\(([^()]+)\)/g, r=> {
|
|
1132
|
+
if (r[1]) {
|
|
1133
|
+
let matchStr
|
|
1134
|
+
try {
|
|
1135
|
+
matchStr = evalVal(r[1])
|
|
1136
|
+
} catch (e) {}
|
|
1137
|
+
if (matchStr) {
|
|
1138
|
+
temp.push(filterRequire(parseUniqueName(uniqueName)[0], matchStr))
|
|
1139
|
+
}
|
|
1140
|
+
}
|
|
1141
|
+
});
|
|
1142
|
+
regEach(text, /\$requires\s*\(([^()]+)\)/g, r=> {
|
|
1143
|
+
if (r[1]) {
|
|
1144
|
+
for (const item of r[1].split(/,/)) {
|
|
1145
|
+
let matchStr
|
|
1146
|
+
try {
|
|
1147
|
+
matchStr = evalVal(item)
|
|
1148
|
+
} catch (e) {}
|
|
1149
|
+
if (matchStr) {
|
|
1150
|
+
temp.push(filterRequire(parseUniqueName(uniqueName)[0], matchStr))
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1153
|
+
}
|
|
1154
|
+
});
|
|
1155
|
+
temp = [...new Set(temp)]
|
|
1156
|
+
temp.forEach(i => {
|
|
1157
|
+
if (links.indexOf(i) !== -1) {
|
|
1158
|
+
let items = [...links, i];
|
|
1159
|
+
let errorStr = items.map(item => item === i ? warnStr(item):item).join("->")
|
|
1160
|
+
throw `circle deps: ${errorStr}`
|
|
1161
|
+
}
|
|
1162
|
+
})
|
|
1163
|
+
cmds.push(...temp)
|
|
1164
|
+
for (let un of temp) {
|
|
1165
|
+
_getScriptRequires(un, cmds, [...links, un])
|
|
1166
|
+
}
|
|
1167
|
+
}
|
|
1168
|
+
|
|
1169
|
+
function getScriptRequires(uniqueName) {
|
|
1170
|
+
let cmds = [];
|
|
1171
|
+
_getScriptRequires(uniqueName, cmds, [uniqueName]);
|
|
1172
|
+
return [...new Set(cmds)]
|
|
1173
|
+
}
|
|
1096
1174
|
|
|
1097
1175
|
function getComments(i, cmdName, text, cols = [], col) {
|
|
1098
1176
|
let docLines = [infoStr(getCmdMd5Key(parseUniqueName(cmdName)[1])) + " - " + infoStr(i)]
|
|
@@ -1429,9 +1507,11 @@ function getArgDef(text) {
|
|
|
1429
1507
|
}
|
|
1430
1508
|
|
|
1431
1509
|
function setTips(key, value, onRm) {
|
|
1432
|
-
global.$tips[
|
|
1510
|
+
let vals = getOr(global.$tips, key, []);
|
|
1511
|
+
vals.push(value)
|
|
1512
|
+
global.$tips[key] = [...new Set(vals)]
|
|
1433
1513
|
if (onRm) {
|
|
1434
|
-
_tipsOnRm[
|
|
1514
|
+
getOr(_tipsOnRm, key, []).push(onRm)
|
|
1435
1515
|
}
|
|
1436
1516
|
}
|
|
1437
1517
|
|
|
@@ -1453,14 +1533,16 @@ function delTips(...keys) {
|
|
|
1453
1533
|
}
|
|
1454
1534
|
|
|
1455
1535
|
function tipsOnRmCallback(key) {
|
|
1456
|
-
let
|
|
1536
|
+
let callbacks = _tipsOnRm[key]
|
|
1457
1537
|
delete _tipsOnRm[key]
|
|
1458
|
-
if (
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1538
|
+
if (callbacks && callbacks.length > 0) {
|
|
1539
|
+
for (let callback of callbacks) {
|
|
1540
|
+
try {
|
|
1541
|
+
callback()
|
|
1542
|
+
} catch (e) {
|
|
1543
|
+
$log(errorStack(e))
|
|
1544
|
+
error(`[${key}] OnRmCallback: ${String(e)}`)
|
|
1545
|
+
}
|
|
1464
1546
|
}
|
|
1465
1547
|
}
|
|
1466
1548
|
}
|
|
@@ -1469,13 +1551,11 @@ function getCmdMd5Key(str) {
|
|
|
1469
1551
|
return '0x' + md5(str).substr(0, 8);
|
|
1470
1552
|
}
|
|
1471
1553
|
|
|
1472
|
-
|
|
1473
|
-
cmdMatchStr
|
|
1474
|
-
|
|
1475
|
-
if (cmdMatchStr.startsWith("*")) {
|
|
1476
|
-
nullable = true;
|
|
1477
|
-
cmdMatchStr = trim(cmdMatchStr.substr(1));
|
|
1554
|
+
function filterRequire(currSpace, cmdMatchStr) {
|
|
1555
|
+
if (typeof cmdMatchStr === 'number') {
|
|
1556
|
+
cmdMatchStr = '0x' + pad(8, BigNumber(cmdMatchStr).toString(16), '0');
|
|
1478
1557
|
}
|
|
1558
|
+
cmdMatchStr = trim(cmdMatchStr);
|
|
1479
1559
|
|
|
1480
1560
|
let cmds;
|
|
1481
1561
|
let uName = toUniqueName(cmdMatchStr, currSpace)
|
|
@@ -1494,30 +1574,22 @@ async function _requireSource(currSpace, cmdMatchStr, printLog = false) {
|
|
|
1494
1574
|
cmds = cmds.filter(cmd => parseUniqueName(cmd)[0] === (appointSpace || currSpace))
|
|
1495
1575
|
}
|
|
1496
1576
|
}
|
|
1497
|
-
if (cmds.length
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
}
|
|
1501
|
-
throw `none unique match: ${cmdMatchStr}`
|
|
1577
|
+
if (cmds.length > 1) {
|
|
1578
|
+
throw `multiple match: ${cmdMatchStr}`
|
|
1579
|
+
} else if (cmds.length < 1) {
|
|
1580
|
+
throw `none match: ${cmdMatchStr}`
|
|
1502
1581
|
}
|
|
1582
|
+
return cmds[0];
|
|
1583
|
+
}
|
|
1503
1584
|
|
|
1585
|
+
async function _requireSource(currSpace, cmdMatchStr) {
|
|
1504
1586
|
let result
|
|
1505
|
-
let uniqueName =
|
|
1587
|
+
let uniqueName = filterRequire(currSpace, cmdMatchStr);
|
|
1506
1588
|
let path = getFullPath(uniqueName)
|
|
1507
1589
|
let text = String(_fs.readFileSync(path))
|
|
1508
1590
|
let pair = parseUniqueName(uniqueName)
|
|
1509
1591
|
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
|
-
}
|
|
1592
|
+
result = await evalText(text, uniqueName)
|
|
1521
1593
|
} else if (pair[1].startsWith('e ')) {
|
|
1522
1594
|
result = async (argsStr) => {
|
|
1523
1595
|
return await runCmd(trim(argsStr), uniqueName, text)
|
|
@@ -1526,37 +1598,24 @@ async function _requireSource(currSpace, cmdMatchStr, printLog = false) {
|
|
|
1526
1598
|
result = text;
|
|
1527
1599
|
}
|
|
1528
1600
|
if (!vl(result)) {
|
|
1529
|
-
if (nullable) {
|
|
1530
|
-
return null;
|
|
1531
|
-
}
|
|
1532
1601
|
throw `invalid result: ${cmdMatchStr}`
|
|
1533
1602
|
}
|
|
1534
1603
|
if (getType(result) === 'Function' || getType(result) === 'AsyncFunction') {
|
|
1535
1604
|
let tmp = result;
|
|
1536
1605
|
result = (...args) => {
|
|
1537
1606
|
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
1607
|
try {
|
|
1545
1608
|
resp = tmp(...args)
|
|
1546
1609
|
if (getType(resp) === 'Promise') {
|
|
1547
1610
|
return resp.then(result => {
|
|
1548
|
-
pl();
|
|
1549
1611
|
return Promise.resolve(result);
|
|
1550
1612
|
}).catch(e => {
|
|
1551
|
-
pl();
|
|
1552
1613
|
return Promise.reject(errorTag(e, uniqueName))
|
|
1553
1614
|
})
|
|
1554
1615
|
} else {
|
|
1555
|
-
pl();
|
|
1556
1616
|
return resp;
|
|
1557
1617
|
}
|
|
1558
1618
|
} catch (e) {
|
|
1559
|
-
pl();
|
|
1560
1619
|
throw errorTag(e, uniqueName);
|
|
1561
1620
|
}
|
|
1562
1621
|
}
|
|
@@ -1564,27 +1623,6 @@ async function _requireSource(currSpace, cmdMatchStr, printLog = false) {
|
|
|
1564
1623
|
return result
|
|
1565
1624
|
}
|
|
1566
1625
|
|
|
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
1626
|
async function evalText($text = '', $cmdName = '', $args = []) {
|
|
1589
1627
|
let currSpace;
|
|
1590
1628
|
if ($cmdName) {
|
|
@@ -1594,10 +1632,14 @@ async function evalText($text = '', $cmdName = '', $args = []) {
|
|
|
1594
1632
|
currSpace = $defaultSpace
|
|
1595
1633
|
}
|
|
1596
1634
|
let $requires = async (...matchItems) => {
|
|
1597
|
-
|
|
1635
|
+
let result = []
|
|
1636
|
+
for (let i = 0; i < matchItems.length; i++) {
|
|
1637
|
+
result.push(await _requireSource(currSpace, matchItems[i]))
|
|
1638
|
+
}
|
|
1639
|
+
return result
|
|
1598
1640
|
}
|
|
1599
|
-
let $require = async (matchItem
|
|
1600
|
-
return
|
|
1641
|
+
let $require = async (matchItem) => {
|
|
1642
|
+
return await _requireSource(currSpace, matchItem)
|
|
1601
1643
|
}
|
|
1602
1644
|
try {
|
|
1603
1645
|
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() {
|