fix(medusa): normalize build path (#8166)
This commit is contained in:
1 parent
2ba400f6f1
commit
d7e79cfa94
1 file changed
+3
-4
@@ -1,6 +1,6 @@
|
|||||||
import { ConfigModule } from "@medusajs/types"
|
import { ConfigModule } from "@medusajs/types"
|
||||||
import { transformFile } from "@swc/core"
|
|
||||||
import { getConfigFile } from "@medusajs/utils"
|
import { getConfigFile } from "@medusajs/utils"
|
||||||
|
import { transformFile } from "@swc/core"
|
||||||
import { existsSync } from "node:fs"
|
import { existsSync } from "node:fs"
|
||||||
import { copyFile, mkdir, readdir, rm, writeFile } from "node:fs/promises"
|
import { copyFile, mkdir, readdir, rm, writeFile } from "node:fs/promises"
|
||||||
import path from "path"
|
import path from "path"
|
||||||
@@ -56,7 +56,7 @@ const getOutputPath = (file: string, config: FileConfig) => {
|
|||||||
outputPath = outputPath.replace(currentExtension, targetExtension)
|
outputPath = outputPath.replace(currentExtension, targetExtension)
|
||||||
}
|
}
|
||||||
|
|
||||||
return outputPath
|
return outputPath.replaceAll(path.sep, "/")
|
||||||
}
|
}
|
||||||
|
|
||||||
const writeToOut = async (
|
const writeToOut = async (
|
||||||
@@ -72,9 +72,8 @@ const writeToOut = async (
|
|||||||
|
|
||||||
async function copyToOut(file: string, config: FileConfig) {
|
async function copyToOut(file: string, config: FileConfig) {
|
||||||
const outputPath = getOutputPath(file, config)
|
const outputPath = getOutputPath(file, config)
|
||||||
const dirNameRegex = new RegExp("\\" + path.sep + "([^\\" + path.sep + "]+)$")
|
|
||||||
|
|
||||||
await mkdir(outputPath.replace(dirNameRegex, ""), { recursive: true })
|
await mkdir(outputPath.replace(/\/[^/]+$/, ""), { recursive: true })
|
||||||
await copyFile(file, outputPath)
|
await copyFile(file, outputPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user