fix(scirpt): normalize filepath when working in window

pull/363/head
CHOYSEN 4 years ago
parent e74c5f06d1
commit adb43eb8f1

@ -1,10 +1,12 @@
const fs = require('fs-extra') const fs = require('fs-extra')
const glob = require('globby') const glob = require('globby')
const { normalizePath } = require('vite')
function toDest(file) { function toDist(file) {
file = normalizePath(file)
return file.replace(/^src\//, 'dist/') return file.replace(/^src\//, 'dist/')
} }
glob.sync('src/client/**/!(*.ts|tsconfig.json)').forEach((file) => { glob.sync('src/client/**/!(*.ts|tsconfig.json)').forEach((file) => {
fs.copy(file, toDest(file)) fs.copy(file, toDist(file))
}) })

@ -1,7 +1,9 @@
const fs = require('fs-extra') const fs = require('fs-extra')
const chokidar = require('chokidar') const chokidar = require('chokidar')
const { normalizePath } = require('vite')
function toClientAndNode(method, file) { function toClientAndNode(method, file) {
file = normalizePath(file)
if (method === 'copy') { if (method === 'copy') {
fs.copy(file, file.replace(/^src\/shared\//, 'src/node/')) fs.copy(file, file.replace(/^src\/shared\//, 'src/node/'))
fs.copy(file, file.replace(/^src\/shared\//, 'src/client/')) fs.copy(file, file.replace(/^src\/shared\//, 'src/client/'))
@ -12,6 +14,7 @@ function toClientAndNode(method, file) {
} }
function toDist(file) { function toDist(file) {
file = normalizePath(file)
return file.replace(/^src\//, 'dist/') return file.replace(/^src\//, 'dist/')
} }

Loading…
Cancel
Save