From 6a1fb4d4c65ff5caa769825dc640f4d4a8b1a9f7 Mon Sep 17 00:00:00 2001 From: Wojciech Maj Date: Thu, 11 Jul 2024 20:25:06 +0200 Subject: [PATCH 1/2] chore: use renameSafe where applicable Code I removed is literally renameSafe's body, so I replaced it with renameSafe. --- sources/corepackUtils.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/sources/corepackUtils.ts b/sources/corepackUtils.ts index a1f3a0851..2f03788e1 100644 --- a/sources/corepackUtils.ts +++ b/sources/corepackUtils.ts @@ -305,11 +305,7 @@ export async function installVersion(installTarget: string, locator: Locator, {s await fs.promises.mkdir(path.dirname(installFolder), {recursive: true}); try { - if (process.platform === `win32`) { - await renameUnderWindows(tmpFolder, installFolder); - } else { - await fs.promises.rename(tmpFolder, installFolder); - } + renameSafe(tmpFolder, installFolder); } catch (err) { if ( (err as nodeUtils.NodeError).code === `ENOTEMPTY` || From 373126a1bdf59bdac61d684a2ab168203bc6d8b3 Mon Sep 17 00:00:00 2001 From: Wojciech Maj Date: Thu, 11 Jul 2024 22:16:25 +0200 Subject: [PATCH 2/2] Apply suggestion Co-authored-by: Kristoffer K. --- sources/corepackUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/corepackUtils.ts b/sources/corepackUtils.ts index 2f03788e1..c77589c98 100644 --- a/sources/corepackUtils.ts +++ b/sources/corepackUtils.ts @@ -305,7 +305,7 @@ export async function installVersion(installTarget: string, locator: Locator, {s await fs.promises.mkdir(path.dirname(installFolder), {recursive: true}); try { - renameSafe(tmpFolder, installFolder); + await renameSafe(tmpFolder, installFolder); } catch (err) { if ( (err as nodeUtils.NodeError).code === `ENOTEMPTY` ||