feat:Fix sometimes mapping merged twice
This commit is contained in:
parent
cf888e3655
commit
cd74a60c9e
@ -60,6 +60,11 @@ async function doMerge(jsFile: string) {
|
|||||||
|
|
||||||
|
|
||||||
export async function mergeMap(mapFile: string) {
|
export async function mergeMap(mapFile: string) {
|
||||||
|
const mapContent = await fs.promises.readFile(mapFile, "utf-8");
|
||||||
|
if (JSON.parse(mapContent).merged) {
|
||||||
|
console.log("Already merged");
|
||||||
|
return;
|
||||||
|
}
|
||||||
const lockFile = `${mapFile}.lock`;
|
const lockFile = `${mapFile}.lock`;
|
||||||
if (fs.existsSync(lockFile)) {
|
if (fs.existsSync(lockFile)) {
|
||||||
console.log("In mergeMap,skip")
|
console.log("In mergeMap,skip")
|
||||||
@ -72,8 +77,10 @@ export async function mergeMap(mapFile: string) {
|
|||||||
const mergedMap = createMergedSourceMapFromFiles([
|
const mergedMap = createMergedSourceMapFromFiles([
|
||||||
buildMap,
|
buildMap,
|
||||||
mapFile,
|
mapFile,
|
||||||
], true);
|
], true) as string;
|
||||||
await fs.promises.writeFile(mapFile, mergedMap);
|
const mapObj = JSON.parse(mergedMap);
|
||||||
|
mapObj.merged = true
|
||||||
|
await fs.promises.writeFile(mapFile, JSON.stringify(mapObj), "utf-8");
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
await fs.promises.unlink(lockFile)
|
await fs.promises.unlink(lockFile)
|
||||||
|
Reference in New Issue
Block a user