Skip to content

Commit

Permalink
refactor: more agnostic copying of files
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianWoelki committed Jun 29, 2024
1 parent 7e9184a commit f51ad23
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion copy-file.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import fs from 'fs/promises';
import path from 'path';

const copyFile = (options = {}) => {
const { targets = [], hook = 'writeBundle' } = options;
Expand All @@ -8,7 +9,7 @@ const copyFile = (options = {}) => {
targets.forEach(async (target) => {
try {
console.log(`copying ${target.src}...`);
const destPath = target.dest + target.src.split('/').pop();
const destPath = path.join(target.dest, path.basename(target.src));
await fs.copyFile(target.src, destPath);
} catch (error) {
console.log(error);
Expand Down

0 comments on commit f51ad23

Please sign in to comment.