File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ use std:: { collections:: HashMap , iter} ;
2+
3+ use crate :: package_manager:: { PackageManager , ResolveCommandResult , format_path_env} ;
4+
5+ impl PackageManager {
6+ /// Resolve the install command.
7+ pub fn resolve_install_command ( & self , args : & Vec < String > ) -> ResolveCommandResult {
8+ ResolveCommandResult {
9+ bin_path : self . bin_name . to_string ( ) ,
10+ args : iter:: once ( "install" )
11+ . chain ( args. iter ( ) . map ( String :: as_str) )
12+ . map ( String :: from)
13+ . collect ( ) ,
14+ envs : HashMap :: from ( [ ( "PATH" . to_string ( ) , format_path_env ( self . get_bin_prefix ( ) ) ) ] ) ,
15+ }
16+ }
17+ }
Original file line number Diff line number Diff line change 11mod config;
2+ mod install;
23pub mod package;
34pub mod package_manager;
45mod request;
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ async fn main() -> Result<(), Error> {
88 let package_manager = PackageManager :: builder ( & current_dir) . build ( ) . await ?;
99 println ! ( "Package manager: {package_manager:#?} for {current_dir:?}" ) ;
1010
11- let resolve_command = package_manager. resolve_command ( ) ;
11+ let resolve_command = package_manager. resolve_install_command ( & vec ! [ ] ) ;
1212 println ! ( "Resolve command: {resolve_command:#?}" ) ;
1313
1414 Ok ( ( ) )
Original file line number Diff line number Diff line change @@ -50,6 +50,7 @@ impl fmt::Display for PackageManagerType {
5050#[ derive( Debug ) ]
5151pub struct ResolveCommandResult {
5252 pub bin_path : String ,
53+ pub args : Vec < String > ,
5354 pub envs : HashMap < String , String > ,
5455}
5556
@@ -146,14 +147,6 @@ impl PackageManager {
146147 self . install_dir . join ( "bin" )
147148 }
148149
149- #[ must_use]
150- pub fn resolve_command ( & self ) -> ResolveCommandResult {
151- ResolveCommandResult {
152- bin_path : self . bin_name . to_string ( ) ,
153- envs : HashMap :: from ( [ ( "PATH" . to_string ( ) , format_path_env ( self . get_bin_prefix ( ) ) ) ] ) ,
154- }
155- }
156-
157150 #[ must_use]
158151 pub fn get_fingerprint_ignores ( & self ) -> Vec < Str > {
159152 let mut ignores: Vec < Str > = vec ! [
@@ -601,7 +594,7 @@ async fn set_package_manager_field(
601594 Ok ( ( ) )
602595}
603596
604- fn format_path_env ( bin_prefix : impl AsRef < Path > ) -> String {
597+ pub ( crate ) fn format_path_env ( bin_prefix : impl AsRef < Path > ) -> String {
605598 let mut paths = env:: split_paths ( & env:: var_os ( "PATH" ) . unwrap_or_default ( ) ) . collect :: < Vec < _ > > ( ) ;
606599 paths. insert ( 0 , bin_prefix. as_ref ( ) . to_path_buf ( ) ) ;
607600 env:: join_paths ( paths) . unwrap ( ) . to_string_lossy ( ) . to_string ( )
Original file line number Diff line number Diff line change 11use std:: {
22 env,
33 io:: { self , IsTerminal , Write } ,
4- iter,
54} ;
65
76use crossterm:: {
@@ -59,11 +58,11 @@ impl InstallCommand {
5958 Err ( e) => return Err ( e) ,
6059 } ;
6160 let workspace = Workspace :: partial_load ( self . workspace_root ) ?;
62- let resolve_command = package_manager. resolve_command ( ) ;
61+ let resolve_command = package_manager. resolve_install_command ( args ) ;
6362 let resolved_task = ResolvedTask :: resolve_from_builtin_with_command_result (
6463 & workspace,
6564 "install" ,
66- iter :: once ( "install" ) . chain ( args. iter ( ) . map ( String :: as_str ) ) ,
65+ resolve_command . args . iter ( ) ,
6766 ResolveCommandResult { bin_path : resolve_command. bin_path , envs : resolve_command. envs } ,
6867 self . ignore_replay ,
6968 Some ( package_manager. get_fingerprint_ignores ( ) ) ,
You can’t perform that action at this time.
0 commit comments