node-automator 1.4.19 → 1.4.20
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/merge_file.js +25 -0
- package/commands/mgr.js +4 -0
- package/commands/split_file.js +39 -0
- package/package.json +2 -1
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const { get_file_list, get_full_path } = require('../utils/file_tool');
|
|
2
|
+
const { BaseCommand } = require("./base");
|
|
3
|
+
|
|
4
|
+
class MergeFileCommand extends BaseCommand {
|
|
5
|
+
async execute() {
|
|
6
|
+
const splitFile = require('split-file');
|
|
7
|
+
let { src, dst } = this.selfData;
|
|
8
|
+
src = get_file_list(src);
|
|
9
|
+
dst = get_full_path(dst);
|
|
10
|
+
const names = await new Promise((resolve, reject) => {
|
|
11
|
+
splitFile.mergeFiles(src, dst)
|
|
12
|
+
.then((names) => {
|
|
13
|
+
resolve(names);
|
|
14
|
+
})
|
|
15
|
+
.catch((err) => {
|
|
16
|
+
reject(err);
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
return names;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
module.exports = {
|
|
24
|
+
MergeFileCommand,
|
|
25
|
+
};
|
package/commands/mgr.js
CHANGED
|
@@ -120,6 +120,8 @@ const { BackupCommand } = require('./backup');
|
|
|
120
120
|
const { CompressCommand } = require('./compress');
|
|
121
121
|
const { Word2txtCommand } = require('./word2txt');
|
|
122
122
|
const { ObfuscateCommand } = require('./obfuscate');
|
|
123
|
+
const { SplitFileCommand } = require('./split_file');
|
|
124
|
+
const { MergeFileCommand } = require('./merge_file');
|
|
123
125
|
|
|
124
126
|
const globalData = {
|
|
125
127
|
"executed_cfg": [], // 执行过的配置文件
|
|
@@ -483,6 +485,8 @@ function init() {
|
|
|
483
485
|
register("compress", CompressCommand, false);
|
|
484
486
|
register("word2txt", Word2txtCommand, false);
|
|
485
487
|
register("obfuscate", ObfuscateCommand, false);
|
|
488
|
+
register("split_file", SplitFileCommand, false);
|
|
489
|
+
register("merge_file", MergeFileCommand, false);
|
|
486
490
|
}
|
|
487
491
|
|
|
488
492
|
module.exports = {
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
const { get_fst_file, get_full_path } = require('../utils/file_tool');
|
|
2
|
+
const { getByteSize } = require('../utils/transform_tool');
|
|
3
|
+
const { BaseCommand } = require("./base");
|
|
4
|
+
|
|
5
|
+
class SplitFileCommand extends BaseCommand {
|
|
6
|
+
async execute() {
|
|
7
|
+
const splitFile = require('split-file');
|
|
8
|
+
let { src, maxSize, numParts, dst } = this.selfData;
|
|
9
|
+
src = get_fst_file(src);
|
|
10
|
+
dst = get_full_path(dst, "FOLDER");
|
|
11
|
+
maxSize = getByteSize(maxSize);
|
|
12
|
+
const names = await new Promise((resolve, reject) => {
|
|
13
|
+
if (maxSize) {
|
|
14
|
+
splitFile.splitFileBySize(src, maxSize, dst)
|
|
15
|
+
.then((names) => {
|
|
16
|
+
resolve(names);
|
|
17
|
+
})
|
|
18
|
+
.catch((err) => {
|
|
19
|
+
reject(err);
|
|
20
|
+
});
|
|
21
|
+
} else if (numParts) {
|
|
22
|
+
splitFile.splitFile(src, numParts, dst)
|
|
23
|
+
.then((names) => {
|
|
24
|
+
resolve(names);
|
|
25
|
+
})
|
|
26
|
+
.catch((err) => {
|
|
27
|
+
reject(err);
|
|
28
|
+
});
|
|
29
|
+
} else {
|
|
30
|
+
reject("maxSize or numParts is required");
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
return names;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
module.exports = {
|
|
38
|
+
SplitFileCommand,
|
|
39
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-automator",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.20",
|
|
4
4
|
"description": "Execute automation with yaml configuration(compatible with json)",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": {
|
|
@@ -53,6 +53,7 @@
|
|
|
53
53
|
"request": "^2.88.2",
|
|
54
54
|
"request-progress": "^3.0.0",
|
|
55
55
|
"sharp": "^0.34.3",
|
|
56
|
+
"split-file": "^2.3.0",
|
|
56
57
|
"spreadsheet-column": "^1.1.1",
|
|
57
58
|
"strip-json-comments": "^3.1.1",
|
|
58
59
|
"temp": "^0.9.4",
|