File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -207,7 +207,7 @@ async fn do_install(
207207 print_warn ( & format ! ( "Node.js manager setup failed (non-fatal): {e}" ) ) ;
208208 }
209209 } else {
210- if let Err ( e) = create_env_files ( install_dir) . await {
210+ if let Err ( e) = install :: create_env_files ( install_dir) . await {
211211 print_warn ( & format ! ( "Env file creation failed (non-fatal): {e}" ) ) ;
212212 }
213213 }
@@ -353,23 +353,6 @@ async fn download_with_progress(
353353 Ok ( data)
354354}
355355
356- async fn create_env_files (
357- install_dir : & vite_path:: AbsolutePath ,
358- ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
359- let vp_binary = install_dir. join ( "current" ) . join ( "bin" ) . join ( VP_BINARY_NAME ) ;
360-
361- if !tokio:: fs:: try_exists ( & vp_binary) . await . unwrap_or ( false ) {
362- return Ok ( ( ) ) ;
363- }
364-
365- tokio:: process:: Command :: new ( vp_binary. as_path ( ) )
366- . args ( [ "env" , "setup" , "--env-only" ] )
367- . output ( )
368- . await ?;
369-
370- Ok ( ( ) )
371- }
372-
373356fn resolve_install_dir ( opts : & cli:: Options ) -> Result < AbsolutePathBuf , Box < dyn std:: error:: Error > > {
374357 if let Some ( ref dir) = opts. install_dir {
375358 let path = std:: path:: PathBuf :: from ( dir) ;
Original file line number Diff line number Diff line change @@ -319,6 +319,26 @@ pub async fn refresh_shims(install_dir: &AbsolutePath) -> Result<(), Error> {
319319 Ok ( ( ) )
320320}
321321
322+ /// Create shell env files by running `vp env setup --env-only`.
323+ ///
324+ /// Used when the Node.js manager is disabled — ensures env files exist
325+ /// even without a full shim refresh.
326+ pub async fn create_env_files ( install_dir : & AbsolutePath ) -> Result < ( ) , Error > {
327+ let vp_binary =
328+ install_dir. join ( "current" ) . join ( "bin" ) . join ( if cfg ! ( windows) { "vp.exe" } else { "vp" } ) ;
329+
330+ if !tokio:: fs:: try_exists ( & vp_binary) . await . unwrap_or ( false ) {
331+ return Ok ( ( ) ) ;
332+ }
333+
334+ tokio:: process:: Command :: new ( vp_binary. as_path ( ) )
335+ . args ( [ "env" , "setup" , "--env-only" ] )
336+ . output ( )
337+ . await ?;
338+
339+ Ok ( ( ) )
340+ }
341+
322342/// Clean up old version directories, keeping at most `max_keep` versions.
323343///
324344/// Sorts by creation time (newest first, matching install.sh behavior) and removes
You can’t perform that action at this time.
0 commit comments