Skip to content

Commit f51ad23

Browse files
committed
refactor: more agnostic copying of files
1 parent 7e9184a commit f51ad23

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

copy-file.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import fs from 'fs/promises';
2+
import path from 'path';
23

34
const copyFile = (options = {}) => {
45
const { targets = [], hook = 'writeBundle' } = options;
@@ -8,7 +9,7 @@ const copyFile = (options = {}) => {
89
targets.forEach(async (target) => {
910
try {
1011
console.log(`copying ${target.src}...`);
11-
const destPath = target.dest + target.src.split('/').pop();
12+
const destPath = path.join(target.dest, path.basename(target.src));
1213
await fs.copyFile(target.src, destPath);
1314
} catch (error) {
1415
console.log(error);

0 commit comments

Comments
 (0)