From adb43eb8f154d1ffd159efa7bd83e1b23931260d Mon Sep 17 00:00:00 2001 From: CHOYSEN Date: Sat, 14 Aug 2021 15:11:19 +0800 Subject: [PATCH] fix(scirpt): normalize filepath when working in window --- scripts/copyClient.js | 6 ++++-- scripts/watchAndCopy.js | 3 +++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/scripts/copyClient.js b/scripts/copyClient.js index 5f6e0f7c..576aeaf3 100644 --- a/scripts/copyClient.js +++ b/scripts/copyClient.js @@ -1,10 +1,12 @@ const fs = require('fs-extra') const glob = require('globby') +const { normalizePath } = require('vite') -function toDest(file) { +function toDist(file) { + file = normalizePath(file) return file.replace(/^src\//, 'dist/') } glob.sync('src/client/**/!(*.ts|tsconfig.json)').forEach((file) => { - fs.copy(file, toDest(file)) + fs.copy(file, toDist(file)) }) diff --git a/scripts/watchAndCopy.js b/scripts/watchAndCopy.js index 806b41cd..c1386ccb 100644 --- a/scripts/watchAndCopy.js +++ b/scripts/watchAndCopy.js @@ -1,7 +1,9 @@ const fs = require('fs-extra') const chokidar = require('chokidar') +const { normalizePath } = require('vite') function toClientAndNode(method, file) { + file = normalizePath(file) if (method === 'copy') { fs.copy(file, file.replace(/^src\/shared\//, 'src/node/')) fs.copy(file, file.replace(/^src\/shared\//, 'src/client/')) @@ -12,6 +14,7 @@ function toClientAndNode(method, file) { } function toDist(file) { + file = normalizePath(file) return file.replace(/^src\//, 'dist/') }