Skip to content

Commit

Permalink
Ignore EBUSY error when deleting temporary directory under Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
niklashigi committed Feb 5, 2022
1 parent d259da7 commit 6c57231
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,17 @@ async function main() {
)

if (!args.keep) {
await rm(tmpDir, { recursive: true, force: true })
try {
await rm(tmpDir, { recursive: true, force: true })
} catch (error: any) {
// No idea why Windows gives us an `EBUSY: resource busy or locked`
// error here, but deleting the temporary directory isn't the most
// important thing in the world, so let's just ignore it
const ignoreError =
process.platform === 'win32' && error.code === 'EBUSY'

if (!ignoreError) throw error
}
}
})
.catch((error: PatchingError) => {
Expand Down

0 comments on commit 6c57231

Please sign in to comment.