node-automator 1.4.16 → 1.4.17

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.
@@ -1,6 +1,7 @@
1
1
  const path = require('path');
2
2
  const { get_fst_file, get_full_path, move } = require('../utils/file_tool');
3
3
  const { BaseCommand } = require("./base");
4
+ const { readFileSync } = require('fs');
4
5
 
5
6
  class CompressCommand extends BaseCommand {
6
7
  async execute() {
@@ -8,7 +9,6 @@ class CompressCommand extends BaseCommand {
8
9
  const data = this.selfData;
9
10
  const src = get_fst_file(data.src);
10
11
  const dst = get_full_path(data.dst, "FILE");
11
- const tmp = path.join(this.shareData.AUTOMATOR_SCRATCH, path.basename(src));
12
12
  let format = data.format;
13
13
  if (!format) {
14
14
  format = dst.split(".").pop();
@@ -18,9 +18,9 @@ class CompressCommand extends BaseCommand {
18
18
  format = "jpeg";
19
19
  }
20
20
  const options = data.options;
21
- await sharp(src)[format](options)
22
- .toFile(tmp);
23
- await move(tmp, path.dirname(dst), undefined, { quiet: true, rename: path.basename(dst) });
21
+ const fileContent = readFileSync(src);
22
+ await sharp(fileContent)[format](options)
23
+ .toFile(dst);
24
24
  }
25
25
  }
26
26
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-automator",
3
- "version": "1.4.16",
3
+ "version": "1.4.17",
4
4
  "description": "Execute automation with yaml configuration(compatible with json)",
5
5
  "main": "index.js",
6
6
  "repository": {
@@ -311,10 +311,6 @@ async function copy(src, dst, base, options) {
311
311
  actual_files.push(src);
312
312
  }
313
313
  await new Promise(resolve => {
314
- // 如果存在,先删除
315
- if (fs.existsSync(dstFile)) {
316
- fs.unlinkSync(dstFile);
317
- }
318
314
  // !options.overwrite ? fs.constants.COPYFILE_EXCL : 0
319
315
  fs.copyFile(src, dstFile, 0, (err) => {
320
316
  if (err) {
@@ -388,10 +384,6 @@ async function move(src, dst, base, options) {
388
384
  if (!options.overwrite && fs.existsSync(dstFile)) {
389
385
  resolve();
390
386
  } else {
391
- // 如果存在,先删除
392
- if (fs.existsSync(dstFile)) {
393
- fs.unlinkSync(dstFile);
394
- }
395
387
  fs.copyFile(src, dstFile, 0, (err) => {
396
388
  if (err) {
397
389
  throw (err);