From 4556c7eb1bea6b98ae915c2672dbdd2c50f92c64 Mon Sep 17 00:00:00 2001 From: khai96_ Date: Fri, 2 Feb 2024 21:44:30 +0700 Subject: [PATCH] fix: escape slash on windows Fixes https://github.com/pnpm/pnpm/issues/5420 --- lib/installer.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/installer.js b/lib/installer.js index 1c9ae5e..bd6ab29 100644 --- a/lib/installer.js +++ b/lib/installer.js @@ -60,6 +60,10 @@ const locationFromShell = shell => { * @param {SupportedShell} shell - Shell to base the check on */ const sourceLineForShell = (scriptname, shell) => { + // Windows naturally uses `\` as path separator, which would be misinterpreted by the + // shell interpreters. + scriptname = scriptname.replaceAll('\\', '/'); + if (shell === 'fish') { return `[ -f ${scriptname} ]; and . ${scriptname}; or true`; }