@@ -37,13 +37,13 @@ pub enum OutputMode {
3737/// [allow_failure]: BootstrapCommand::allow_failure
3838/// [delay_failure]: BootstrapCommand::delay_failure
3939#[ derive( Debug ) ]
40- pub struct BootstrapCommand < ' a > {
41- pub command : & ' a mut Command ,
40+ pub struct BootstrapCommand {
41+ pub command : Command ,
4242 pub failure_behavior : BehaviorOnFailure ,
4343 pub output_mode : Option < OutputMode > ,
4444}
4545
46- impl < ' a > BootstrapCommand < ' a > {
46+ impl BootstrapCommand {
4747 pub fn delay_failure ( self ) -> Self {
4848 Self { failure_behavior : BehaviorOnFailure :: DelayFail , ..self }
4949 }
@@ -66,8 +66,33 @@ impl<'a> BootstrapCommand<'a> {
6666 }
6767}
6868
69- impl < ' a > From < & ' a mut Command > for BootstrapCommand < ' a > {
69+ /// This implementation is temporary, until all `Command` invocations are migrated to
70+ /// `BootstrapCommand`.
71+ impl < ' a > From < & ' a mut Command > for BootstrapCommand {
7072 fn from ( command : & ' a mut Command ) -> Self {
73+ // This is essentially a manual `Command::clone`
74+ let mut cmd = Command :: new ( command. get_program ( ) ) ;
75+ if let Some ( dir) = command. get_current_dir ( ) {
76+ cmd. current_dir ( dir) ;
77+ }
78+ cmd. args ( command. get_args ( ) ) ;
79+ for ( key, value) in command. get_envs ( ) {
80+ match value {
81+ Some ( value) => {
82+ cmd. env ( key, value) ;
83+ }
84+ None => {
85+ cmd. env_remove ( key) ;
86+ }
87+ }
88+ }
89+
90+ cmd. into ( )
91+ }
92+ }
93+
94+ impl From < Command > for BootstrapCommand {
95+ fn from ( command : Command ) -> Self {
7196 Self { command, failure_behavior : BehaviorOnFailure :: Exit , output_mode : None }
7297 }
7398}
0 commit comments