From 6c572318c5e30ddc2fdf662b8a84bb8d0f5bb55e Mon Sep 17 00:00:00 2001 From: Niklas Higi Date: Sat, 5 Feb 2022 15:57:59 +0100 Subject: [PATCH] Ignore `EBUSY` error when deleting temporary directory under Windows --- src/cli.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/cli.ts b/src/cli.ts index 9036371..2a37a80 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -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) => {