fix:doric-cli when in dev mode,build bundle cause conflict

This commit is contained in:
pengfei.zhou 2021-03-02 11:50:12 +08:00 committed by osborn
parent bdd392e455
commit 4e5b1c94bf

View File

@ -60,6 +60,13 @@ async function doMerge(jsFile: string) {
export async function mergeMap(mapFile: string) {
const lockFile = `${mapFile}.lock`;
if (fs.existsSync(lockFile)) {
console.log("In mergeMap,skip")
return;
}
await fs.promises.writeFile(lockFile, (new Date).toString(), "utf-8")
try {
const buildMap = mapFile.replace(/bundle\//, 'build/')
if (fs.existsSync(buildMap)) {
const mergedMap = createMergedSourceMapFromFiles([
@ -68,4 +75,8 @@ export async function mergeMap(mapFile: string) {
], true);
await fs.promises.writeFile(mapFile, mergedMap);
}
} finally {
await fs.promises.unlink(lockFile)
}
}