Skip to content

Commit

Permalink
fix: do not try to apply treemending patch twice
Browse files Browse the repository at this point in the history
  • Loading branch information
Loïc Mangeonjean committed May 24, 2023
1 parent c0301e3 commit 30cda38
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions src/monaco-treemending.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,15 @@ async function run () {
process.exit(1)
}

const alreadyPatched: boolean = monacoPackageJson.treemended ?? false
if (alreadyPatched) {
// eslint-disable-next-line no-console
console.info('Monaco-editor has already been tree-mended, ignoring')
process.exit(0)
}

function getMonacoFile (diff: ParsedDiff) {
return path.resolve(monacoDirectory, diff.oldFileName!.slice('a/'.length))
return path.resolve(monacoEsmDirectory, diff.oldFileName!.slice('a/'.length))
}

await new Promise<void>((resolve, reject) => {
Expand Down Expand Up @@ -59,11 +66,19 @@ async function run () {
}
})
})
}

run().then(() => {
// Mark monaco as treemended
await fs.writeFile(monacoPackageJsonFile, JSON.stringify({
...monacoPackageJson,
treemended: true
}, null, 2))

// eslint-disable-next-line no-console
console.info('Monaco-editor was tree-mended')
}, err => {
process.exit(0)
}

run().catch(err => {
console.error(err)
process.exit(1)
})

0 comments on commit 30cda38

Please sign in to comment.