node-automator 1.3.12 → 1.3.13
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/commands/exec_from_file.js +2 -1
- package/commands/mgr.js +5 -3
- package/index.js +4 -1
- package/package.json +1 -1
- package/utils/log_tool.js +24 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const { get_file_list, read_cfg, get_fst_file } = require("../utils/file_tool");
|
|
2
|
-
const { whisper, info, warn, success, vital } = require("../utils/log_tool");
|
|
2
|
+
const { whisper, info, warn, success, vital, setLastExecFile } = require("../utils/log_tool");
|
|
3
3
|
const { toArray } = require("../utils/transform_tool");
|
|
4
4
|
const { BaseCommand } = require("./base");
|
|
5
5
|
|
|
@@ -20,6 +20,7 @@ class ExecFromFileCommand extends BaseCommand {
|
|
|
20
20
|
}
|
|
21
21
|
info(`执行配置文件 ${src}`);
|
|
22
22
|
this.globalData.executed_cfg.push(src);
|
|
23
|
+
setLastExecFile(src);
|
|
23
24
|
let cfg = await read_cfg(src, data.type);
|
|
24
25
|
await this.exec(cfg, this.depth + 1);
|
|
25
26
|
}
|
package/commands/mgr.js
CHANGED
|
@@ -2,7 +2,7 @@ const { progress } = require("../utils/display_tool");
|
|
|
2
2
|
const { eval_code } = require("./share_data");
|
|
3
3
|
const { read_plain } = require("../utils/file_tool");
|
|
4
4
|
const { pause } = require("../utils/interaction_tool");
|
|
5
|
-
const { whisper, getPrint, resetError, getLastError, warn, log, error, setLastError } = require("../utils/log_tool");
|
|
5
|
+
const { whisper, getPrint, resetError, getLastError, warn, log, error, setLastError, setLastCommand } = require("../utils/log_tool");
|
|
6
6
|
const { AbortCommand } = require("./abort");
|
|
7
7
|
const { BaseCommand, PROCESS_STATE } = require("./base");
|
|
8
8
|
const { BreakCommand } = require("./break");
|
|
@@ -248,11 +248,13 @@ async function _execSingle(commandCfg, depth, progressData) {
|
|
|
248
248
|
};
|
|
249
249
|
}
|
|
250
250
|
let rawCfg = JSON.stringify(commandCfg, undefined, 4);
|
|
251
|
+
setLastCommand(rawCfg);
|
|
251
252
|
// 深度拷贝
|
|
252
253
|
commandCfg = JSON.parse(rawCfg);
|
|
253
254
|
// 提前format
|
|
254
255
|
if (!commandCfg.raw) {
|
|
255
256
|
formatData(commandCfg);
|
|
257
|
+
setLastCommand(rawCfg, commandCfg);
|
|
256
258
|
}
|
|
257
259
|
if (commandCfg.side_effect && shareData.DRY_RUN) {
|
|
258
260
|
warn(`[DRY_RUN] ${commandCfg.title || commandCfg.type}`);
|
|
@@ -318,7 +320,7 @@ async function _execSingle(commandCfg, depth, progressData) {
|
|
|
318
320
|
}
|
|
319
321
|
if (content == null) {
|
|
320
322
|
if (!commandCfg.ignore_error) {
|
|
321
|
-
throw `无content
|
|
323
|
+
throw `无content可供使用`;
|
|
322
324
|
}
|
|
323
325
|
}
|
|
324
326
|
}
|
|
@@ -344,7 +346,7 @@ async function _execSingle(commandCfg, depth, progressData) {
|
|
|
344
346
|
if (commandCfg.ignore_error) {
|
|
345
347
|
resetError(commandCfg.ignore_error);
|
|
346
348
|
} else {
|
|
347
|
-
throw getLastError()
|
|
349
|
+
throw getLastError();
|
|
348
350
|
}
|
|
349
351
|
}
|
|
350
352
|
if (commandCfg.newline) {
|
package/index.js
CHANGED
|
@@ -27,6 +27,8 @@ const {
|
|
|
27
27
|
error,
|
|
28
28
|
getLastErrorCode,
|
|
29
29
|
error2,
|
|
30
|
+
getLastCommand,
|
|
31
|
+
getLastExecFile,
|
|
30
32
|
} = require("./utils/log_tool");
|
|
31
33
|
const {
|
|
32
34
|
showAlert,
|
|
@@ -87,7 +89,8 @@ async function MainProcess() {
|
|
|
87
89
|
let hasError = code != 0;
|
|
88
90
|
info("");
|
|
89
91
|
if (hasError) {
|
|
90
|
-
|
|
92
|
+
var [lastCommand, lastCommandFormated] = getLastCommand();
|
|
93
|
+
error2("File:\n" + getLastExecFile() + "\nRaw:\n" + lastCommand + "\nFormated:\n" + JSON.stringify(lastCommandFormated, null, 4) + "\n" + lastError);
|
|
91
94
|
}
|
|
92
95
|
if (shareData.VERBOSE) {
|
|
93
96
|
// 非代码启动,需要暂停
|
package/package.json
CHANGED
package/utils/log_tool.js
CHANGED
|
@@ -153,6 +153,26 @@ function resetError(extraError) {
|
|
|
153
153
|
lastErrorCode = null;
|
|
154
154
|
}
|
|
155
155
|
|
|
156
|
+
let lastCommand = null;
|
|
157
|
+
let lastCommandFormated = 0;
|
|
158
|
+
function setLastCommand(raw, formated) {
|
|
159
|
+
lastCommand = raw;
|
|
160
|
+
lastCommandFormated = formated;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function getLastCommand() {
|
|
164
|
+
return [lastCommand, lastCommandFormated];
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
let lastExecFile = null;
|
|
168
|
+
function setLastExecFile(file) {
|
|
169
|
+
lastExecFile = file;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function getLastExecFile() {
|
|
173
|
+
return lastExecFile;
|
|
174
|
+
}
|
|
175
|
+
|
|
156
176
|
function setLogLevel(level) {
|
|
157
177
|
logLevel = level;
|
|
158
178
|
}
|
|
@@ -187,4 +207,8 @@ module.exports = {
|
|
|
187
207
|
omit_offset,
|
|
188
208
|
setLogLevel,
|
|
189
209
|
LogLevel,
|
|
210
|
+
setLastCommand,
|
|
211
|
+
getLastCommand,
|
|
212
|
+
setLastExecFile,
|
|
213
|
+
getLastExecFile,
|
|
190
214
|
};
|