@@ -108,74 +108,22 @@ export function installGlobalCli() {
108108 const binDir = path . join ( installDir , 'bin' ) ;
109109 const currentBinDir = path . join ( installDir , 'current' , 'bin' ) ;
110110
111- // Rename the actual vp binary to vp-raw, then create a wrapper at vp
112- // This ensures VITE_PLUS_HOME is always set when vp is invoked (including via shims)
113- // The wrapper uses `exec -a "$0"` to preserve argv[0] for shim detection
111+ // Create wrapper scripts to ensure VITE_PLUS_HOME is always set
114112 if ( isWindows ) {
115- const vpExe = path . join ( currentBinDir , 'vp.exe' ) ;
116- const vpRawExe = path . join ( currentBinDir , 'vp-raw.exe' ) ;
117-
118- // Rename vp.exe -> vp-raw.exe
119- if ( existsSync ( vpExe ) && ! existsSync ( vpRawExe ) ) {
120- renameSync ( vpExe , vpRawExe ) ;
121- console . log ( `Renamed ${ vpExe } -> ${ vpRawExe } ` ) ;
122- }
123-
124- // Create vp.cmd wrapper in current/bin/ that sets VITE_PLUS_HOME and calls vp-raw.exe
125- const vpWrapperPath = path . join ( currentBinDir , 'vp.cmd' ) ;
126- const vpWrapperContent = `@echo off\r
127- set VITE_PLUS_HOME=${ installDir } \r
128- "%~dp0vp-raw.exe" %*\r
129- exit /b %ERRORLEVEL%\r
130- ` ;
131- writeFileSync ( vpWrapperPath , vpWrapperContent ) ;
132- console . log ( `Created wrapper: ${ vpWrapperPath } ` ) ;
133-
134- // On Windows, create bash script wrappers for Git Bash compatibility
135- // (Git Bash doesn't execute .cmd files automatically)
113+ // On Windows, install.ps1 already creates bin/vp.cmd with VITE_PLUS_HOME set.
114+ // For 'vp-dev', we need to rename it to vp-dev.cmd.
136115 if ( binName === 'vp-dev' ) {
137- // Remove the vp.cmd in bin/ to avoid confusion
138- rmSync ( path . join ( binDir , 'vp.cmd' ) , { force : true } ) ;
139-
140- // Create vp-dev.cmd for cmd.exe/PowerShell
141- const cmdPath = path . join ( binDir , 'vp-dev.cmd' ) ;
142- const cmdContent = `@echo off\r
143- set VITE_PLUS_HOME=${ installDir } \r
144- "%VITE_PLUS_HOME%\\current\\bin\\vp.cmd" %*\r
145- exit /b %ERRORLEVEL%\r
146- ` ;
147- writeFileSync ( cmdPath , cmdContent ) ;
148-
149- // Create vp-dev bash script for Git Bash
150- const bashPath = path . join ( binDir , 'vp-dev' ) ;
151- const bashContent = `#!/bin/bash
152- export VITE_PLUS_HOME="${ installDir } "
153- exec "$VITE_PLUS_HOME/current/bin/vp.cmd" "$@"
154- ` ;
155- writeFileSync ( bashPath , bashContent ) ;
156- console . log ( `\nCreated wrapper scripts: ${ cmdPath } , ${ bashPath } ` ) ;
157- } else {
158- // For 'vp', update bin/vp.cmd to call vp.cmd instead of vp.exe
159- // (install.ps1 creates it pointing to vp.exe, but we renamed that to vp-raw.exe)
160- const cmdPath = path . join ( binDir , 'vp.cmd' ) ;
161- const cmdContent = `@echo off\r
162- set VITE_PLUS_HOME=${ installDir } \r
163- "%VITE_PLUS_HOME%\\current\\bin\\vp.cmd" %*\r
164- exit /b %ERRORLEVEL%\r
165- ` ;
166- writeFileSync ( cmdPath , cmdContent ) ;
167-
168- // Also create bash script wrapper for Git Bash
169- const bashPath = path . join ( binDir , 'vp' ) ;
170- const bashContent = `#!/bin/bash
171- export VITE_PLUS_HOME="${ installDir } "
172- exec "$VITE_PLUS_HOME/current/bin/vp.cmd" "$@"
173- ` ;
174- writeFileSync ( bashPath , bashContent ) ;
175- console . log ( `\nCreated wrapper scripts: ${ cmdPath } , ${ bashPath } ` ) ;
116+ const vpCmd = path . join ( binDir , 'vp.cmd' ) ;
117+ const vpDevCmd = path . join ( binDir , 'vp-dev.cmd' ) ;
118+ if ( existsSync ( vpCmd ) ) {
119+ renameSync ( vpCmd , vpDevCmd ) ;
120+ console . log ( `\nRenamed ${ vpCmd } -> ${ vpDevCmd } ` ) ;
121+ }
176122 }
123+ // For 'vp', bin/vp.cmd is already correct from install.ps1
177124 } else {
178- // Unix: Rename vp -> vp-raw, create wrapper
125+ // Unix: Rename vp -> vp-raw, then create a wrapper at vp
126+ // The wrapper sets VITE_PLUS_HOME and uses `exec -a "$0"` to preserve argv[0] for shim detection
179127 const vpBinary = path . join ( currentBinDir , 'vp' ) ;
180128 const vpRawBinary = path . join ( currentBinDir , 'vp-raw' ) ;
181129
0 commit comments