fix(medusa): normalize build path (#8166)

This commit is contained in:
Carlos R. L. Rodrigues
2024-07-17 09:10:37 -03:00
committed by GitHub
parent 2ba400f6f1
commit d7e79cfa94

View File

@@ -1,6 +1,6 @@
import { ConfigModule } from "@medusajs/types"
import { transformFile } from "@swc/core"
import { getConfigFile } from "@medusajs/utils"
import { transformFile } from "@swc/core"
import { existsSync } from "node:fs"
import { copyFile, mkdir, readdir, rm, writeFile } from "node:fs/promises"
import path from "path"
@@ -56,7 +56,7 @@ const getOutputPath = (file: string, config: FileConfig) => {
outputPath = outputPath.replace(currentExtension, targetExtension)
}
return outputPath
return outputPath.replaceAll(path.sep, "/")
}
const writeToOut = async (
@@ -72,9 +72,8 @@ const writeToOut = async (
async function copyToOut(file: string, config: FileConfig) {
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)
}