node-automator 1.4.8 → 1.4.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/index.js +18 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -38,9 +38,11 @@ const {
|
|
|
38
38
|
parse
|
|
39
39
|
} = require("./utils/parse_tool");
|
|
40
40
|
const {
|
|
41
|
-
shareData
|
|
41
|
+
shareData,
|
|
42
|
+
clear_line_end
|
|
42
43
|
} = require("./commands/share_data");
|
|
43
44
|
const { decode } = require('./utils/base64_tool');
|
|
45
|
+
const { formatTimeInMillisec, formatTimestampMillisec } = require('./utils/transform_tool');
|
|
44
46
|
|
|
45
47
|
process.on('exit', (code) => {
|
|
46
48
|
if (!code) {
|
|
@@ -66,6 +68,15 @@ async function getCfgs() {
|
|
|
66
68
|
});
|
|
67
69
|
}
|
|
68
70
|
async function MainProcess() {
|
|
71
|
+
const enableTimer = argv.ENABLE_TIMER;
|
|
72
|
+
const timerInterval = argv.TIMER_INTERVAL;
|
|
73
|
+
let beginTime = Date.now();
|
|
74
|
+
let timer;
|
|
75
|
+
if (enableTimer && timerInterval) {
|
|
76
|
+
timer = setInterval(() => {
|
|
77
|
+
info(`\r[${formatTimestampMillisec(Date.now())}] 任务已运行 ${formatTimeInMillisec((Date.now() - beginTime), "hh:mm:ss")} ${clear_line_end}`, "");
|
|
78
|
+
}, timerInterval);
|
|
79
|
+
}
|
|
69
80
|
let lastError = null;
|
|
70
81
|
const cfgs = await getCfgs();
|
|
71
82
|
try {
|
|
@@ -84,6 +95,12 @@ async function MainProcess() {
|
|
|
84
95
|
} catch (err) {
|
|
85
96
|
lastError = err.message || err;
|
|
86
97
|
}
|
|
98
|
+
if (enableTimer) {
|
|
99
|
+
clearInterval(timer);
|
|
100
|
+
info("")
|
|
101
|
+
info(`>>> 任务总耗时 ${formatTimeInMillisec((Date.now() - beginTime))} <<<`, undefined, undefined, true);
|
|
102
|
+
}
|
|
103
|
+
|
|
87
104
|
let code = lastError ? (getLastErrorCode() || 1) : 0;
|
|
88
105
|
let extname = path.extname(argv.$0);
|
|
89
106
|
let hasError = code != 0;
|