From f51ad235fd7ffeb4b288760b5004345fd9ece20e Mon Sep 17 00:00:00 2001 From: FlorianWoelki Date: Sat, 29 Jun 2024 09:39:34 +0200 Subject: [PATCH] refactor: more agnostic copying of files --- copy-file.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/copy-file.js b/copy-file.js index 39ebdb3a..4dbae349 100644 --- a/copy-file.js +++ b/copy-file.js @@ -1,4 +1,5 @@ import fs from 'fs/promises'; +import path from 'path'; const copyFile = (options = {}) => { const { targets = [], hook = 'writeBundle' } = options; @@ -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);