node-automator 1.4.7 → 1.4.8

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.
@@ -7,8 +7,7 @@ const fs = require("fs");
7
7
  const path = require("path");
8
8
  const {
9
9
  success,
10
- error,
11
- warn
10
+ error
12
11
  } = require('../utils/log_tool');
13
12
  const {
14
13
  parse,
@@ -51,10 +50,6 @@ class BackupCommand extends BaseCommand {
51
50
  backupData = backupData[key];
52
51
  }
53
52
  }
54
- if (backupData === undefined) {
55
- warn(`未找到 ${filename} 的 ${sourceKeys} 字段`)
56
- return;
57
- }
58
53
  if (backupFormat) {
59
54
  backupData = await stringify(backupData, backupFormat);
60
55
  }
@@ -10,7 +10,6 @@ class CompressCommand extends BaseCommand {
10
10
  const dst = get_full_path(data.dst, "FILE");
11
11
  const options = data.options || {};
12
12
  let image = await Jimp.read(src);
13
- image.scale(options.scale || 1);
14
13
  image.quality(options.quality || 80);
15
14
  await image.writeAsync(dst);
16
15
  }
package/commands/mgr.js CHANGED
@@ -118,7 +118,6 @@ const { DeobfuscateCommand } = require('./deobfuscate');
118
118
  const { AliOssCommand } = require('./ali_oss');
119
119
  const { BackupCommand } = require('./backup');
120
120
  const { CompressCommand } = require('./compress');
121
- const { Word2txtCommand } = require('./word2txt');
122
121
 
123
122
  const globalData = {
124
123
  "executed_cfg": [], // 执行过的配置文件
@@ -480,7 +479,6 @@ function init() {
480
479
  register("ali_oss", AliOssCommand, false);
481
480
  register("backup", BackupCommand, false);
482
481
  register("compress", CompressCommand, false);
483
- register("word2txt", Word2txtCommand, false);
484
482
  }
485
483
 
486
484
  module.exports = {
package/commands/title.js CHANGED
@@ -2,10 +2,13 @@ const { BaseCommand } = require("./base");
2
2
  class TitleCommand extends BaseCommand {
3
3
  async execute() {
4
4
  this.shareData.TITLE = this.content;
5
- await this.forward("shell", {
6
- cmd: ["title", this.content],
7
- shell: true,
8
- });
5
+ // 判断是否为 windows 系统
6
+ if (process.platform === "win32") {
7
+ await this.forward("shell", {
8
+ cmd: ["title", this.content],
9
+ shell: true,
10
+ });
11
+ }
9
12
  }
10
13
 
11
14
  getRequireContent() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-automator",
3
- "version": "1.4.7",
3
+ "version": "1.4.8",
4
4
  "description": "Execute automation with yaml configuration(compatible with json)",
5
5
  "main": "index.js",
6
6
  "repository": {
@@ -41,7 +41,6 @@
41
41
  "log4js": "^6.3.0",
42
42
  "luaparse": "^0.3.1",
43
43
  "mail-watcher": "^0.6.1",
44
- "mammoth": "^1.8.0",
45
44
  "markdown-table": "^2.0.0",
46
45
  "mysql": "^2.18.1",
47
46
  "node-localstorage": "^2.1.6",
@@ -64,7 +64,6 @@ async function exec_shell(data) {
64
64
  let results = [];
65
65
  let errors = [];
66
66
  let encoding = data.encoding || "cp936";
67
- let raw_output = encoding == "raw";
68
67
  !quiet && whisper(`cmd:[${cmd}] cwd:${data.cwd} inputs:${data.inputs}`);
69
68
  options.stdio = ["pipe", capture_stdout ? "pipe" : process.stdout, "pipe"];
70
69
  const child = child_process.spawn(cmd[0], cmd.slice(1), options);
@@ -72,7 +71,7 @@ async function exec_shell(data) {
72
71
  child.stdout.on("data", (chunk) => {
73
72
  results.push(chunk);
74
73
  if (instant_stdout) {
75
- warn(!raw_output ? iconv.decode(chunk, encoding) : chunk.toString());
74
+ warn(iconv.decode(chunk, encoding));
76
75
  }
77
76
  });
78
77
  }
@@ -99,7 +98,7 @@ async function exec_shell(data) {
99
98
  // child.on('close', code => {
100
99
  child.on('exit', code => {
101
100
  if (!data.ignore_code && code != 0) {
102
- let errMsg = !raw_output ? iconv.decode(Buffer.concat(errors), encoding) : Buffer.concat(errors).toString();
101
+ let errMsg = iconv.decode(Buffer.concat(errors), encoding);
103
102
  let isAcceptableErrors = errMsg && acceptableErrors.some(err => {
104
103
  return errMsg.indexOf(err) >= 0;
105
104
  });
@@ -108,7 +107,7 @@ async function exec_shell(data) {
108
107
  }
109
108
  }
110
109
  if (results.length) {
111
- let result = !raw_output ? iconv.decode(Buffer.concat(results), encoding) : Buffer.concat(results);
110
+ let result = iconv.decode(Buffer.concat(results), encoding);
112
111
  if (data.trim) {
113
112
  result = result.trim();
114
113
  }
@@ -1,42 +0,0 @@
1
- const {
2
- get_fst_file
3
- } = require('../utils/file_tool');
4
- const {
5
- BaseCommand
6
- } = require("./base");
7
- const fs = require('fs');
8
- const mammoth = require('mammoth');
9
-
10
- class Word2txtCommand extends BaseCommand {
11
- async execute() {
12
- const data = this.selfData;
13
- const wordFilePath = get_fst_file(data.src);
14
- return new Promise((resolve, reject) => {
15
- // 读取 Word 文件
16
- fs.readFile(wordFilePath, (err, data) => {
17
- if (err) {
18
- reject(err);
19
- return console.error("读取文件时出错:", err);
20
- }
21
-
22
- // 将 Word 文件转换为纯文本
23
- mammoth.extractRawText({
24
- buffer: data
25
- })
26
- .then((result) => {
27
- const text = result.value; // 纯文本内容
28
- console.log("转换后的文本内容:", text);
29
- resolve(text);
30
- })
31
- .catch((err) => {
32
- console.error("转换过程中出错:", err);
33
- reject(err);
34
- });
35
- });
36
- })
37
- }
38
- }
39
-
40
- module.exports = {
41
- Word2txtCommand,
42
- };