node-automator 1.4.15 → 1.4.16
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/compress.js +1 -1
- package/package.json +1 -1
- package/utils/file_tool.js +8 -0
package/commands/compress.js
CHANGED
|
@@ -20,7 +20,7 @@ class CompressCommand extends BaseCommand {
|
|
|
20
20
|
const options = data.options;
|
|
21
21
|
await sharp(src)[format](options)
|
|
22
22
|
.toFile(tmp);
|
|
23
|
-
await move(tmp, path.dirname(dst), undefined, { quiet: true });
|
|
23
|
+
await move(tmp, path.dirname(dst), undefined, { quiet: true, rename: path.basename(dst) });
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
|
package/package.json
CHANGED
package/utils/file_tool.js
CHANGED
|
@@ -311,6 +311,10 @@ 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
|
+
}
|
|
314
318
|
// !options.overwrite ? fs.constants.COPYFILE_EXCL : 0
|
|
315
319
|
fs.copyFile(src, dstFile, 0, (err) => {
|
|
316
320
|
if (err) {
|
|
@@ -384,6 +388,10 @@ async function move(src, dst, base, options) {
|
|
|
384
388
|
if (!options.overwrite && fs.existsSync(dstFile)) {
|
|
385
389
|
resolve();
|
|
386
390
|
} else {
|
|
391
|
+
// 如果存在,先删除
|
|
392
|
+
if (fs.existsSync(dstFile)) {
|
|
393
|
+
fs.unlinkSync(dstFile);
|
|
394
|
+
}
|
|
387
395
|
fs.copyFile(src, dstFile, 0, (err) => {
|
|
388
396
|
if (err) {
|
|
389
397
|
throw (err);
|