@@ -7,7 +7,6 @@ use vite_shared::output;
77
88use crate :: package_manager:: {
99 PackageManager , PackageManagerType , ResolveCommandResult , format_path_env,
10- resolve_global_npm_bin_path,
1110} ;
1211
1312/// Options for the list command.
@@ -39,50 +38,20 @@ impl PackageManager {
3938 options : & ListCommandOptions < ' _ > ,
4039 cwd : impl AsRef < AbsolutePath > ,
4140 ) -> Result < ExitStatus , Error > {
42- let Some ( resolve_command) = self . resolve_list_command_with_global_npm_bin ( options, None )
43- else {
41+ let Some ( resolve_command) = self . resolve_list_command ( options) else {
4442 // Command not supported, return success
4543 return Ok ( ExitStatus :: default ( ) ) ;
4644 } ;
4745 run_command ( & resolve_command. bin_path , & resolve_command. args , & resolve_command. envs , cwd)
4846 . await
4947 }
5048
51- /// Run the list command with an explicit npm binary for global lists.
52- /// Returns ExitStatus with success (0) if the command is not supported.
53- #[ must_use]
54- pub async fn run_list_command_with_global_npm_bin (
55- & self ,
56- options : & ListCommandOptions < ' _ > ,
57- cwd : impl AsRef < AbsolutePath > ,
58- global_npm_bin_path : Option < & AbsolutePath > ,
59- ) -> Result < ExitStatus , Error > {
60- let Some ( resolve_command) =
61- self . resolve_list_command_with_global_npm_bin ( options, global_npm_bin_path)
62- else {
63- return Ok ( ExitStatus :: default ( ) ) ;
64- } ;
65- run_command ( & resolve_command. bin_path , & resolve_command. args , & resolve_command. envs , cwd)
66- . await
67- }
68-
6949 /// Resolve the list command.
7050 /// Returns None if the command is not supported by the package manager.
7151 #[ must_use]
7252 pub fn resolve_list_command (
7353 & self ,
7454 options : & ListCommandOptions ,
75- ) -> Option < ResolveCommandResult > {
76- self . resolve_list_command_with_global_npm_bin ( options, None )
77- }
78-
79- /// Resolve the list command with an explicit npm binary for global lists.
80- /// Returns None if the command is not supported by the package manager.
81- #[ must_use]
82- pub fn resolve_list_command_with_global_npm_bin (
83- & self ,
84- options : & ListCommandOptions ,
85- global_npm_bin_path : Option < & AbsolutePath > ,
8655 ) -> Option < ResolveCommandResult > {
8756 // yarn@2+ does not support list command
8857 if self . client == PackageManagerType :: Yarn && !self . version . starts_with ( "1." ) {
@@ -96,7 +65,7 @@ impl PackageManager {
9665 // Global packages should use npm cli only (since global installs use npm)
9766 let bin_name: String ;
9867 if options. global {
99- bin_name = resolve_global_npm_bin_path ( global_npm_bin_path ) ;
68+ bin_name = "npm" . into ( ) ;
10069 Self :: format_npm_list_args ( & mut args, options) ;
10170 args. push ( "-g" . into ( ) ) ;
10271
@@ -511,24 +480,6 @@ mod tests {
511480 assert_eq ! ( result. args, vec![ "list" , "--depth" , "0" , "-g" ] ) ;
512481 }
513482
514- #[ test]
515- fn test_global_list_uses_explicit_npm_bin ( ) {
516- let pm = create_mock_package_manager ( PackageManagerType :: Pnpm , "10.0.0" ) ;
517- let npm_bin = if cfg ! ( windows) {
518- AbsolutePathBuf :: new ( "C:\\ node\\ npm.cmd" . into ( ) ) . unwrap ( )
519- } else {
520- AbsolutePathBuf :: new ( "/node/bin/npm" . into ( ) ) . unwrap ( )
521- } ;
522- let result = pm
523- . resolve_list_command_with_global_npm_bin (
524- & ListCommandOptions { global : true , ..Default :: default ( ) } ,
525- Some ( & npm_bin) ,
526- )
527- . unwrap ( ) ;
528- assert_eq ! ( result. bin_path, npm_bin. as_path( ) . display( ) . to_string( ) ) ;
529- assert_eq ! ( result. args, vec![ "list" , "-g" ] ) ;
530- }
531-
532483 #[ test]
533484 fn test_pnpm_list_with_filter ( ) {
534485 let pm = create_mock_package_manager ( PackageManagerType :: Pnpm , "10.0.0" ) ;
0 commit comments