From d378896e310921e30e4a91bd62bab23d8e8e073f Mon Sep 17 00:00:00 2001 From: macdonst Date: Wed, 15 May 2024 16:30:50 -0400 Subject: [PATCH] Fix path renaming Signed-off-by: macdonst --- src/utils.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/utils.js b/src/utils.js index dfbfc24..206eb23 100644 --- a/src/utils.js +++ b/src/utils.js @@ -1,4 +1,5 @@ const { copyFileSync, mkdirSync, statSync } = require('fs') +const { join, normalize, sep } = require('path') const { globSync } = require('glob') const SRC_DIR = 'ts' @@ -12,7 +13,9 @@ function copyAllFiles () { } function copyOneFile (srcPath) { - const destPath = srcPath.replace(SRC_DIR, DEST_DIR) + const cwd = process.cwd() + const src = srcPath.startsWith(sep) ? normalize(srcPath) : join(cwd, srcPath) + const destPath = src.replace(join(cwd, SRC_DIR), join(cwd, DEST_DIR)) const stats = statSync(srcPath) if (stats.isDirectory()) { mkdirSync(destPath, { recursive: true })