@@ -575,13 +575,18 @@ impl TurboJson {
575
575
}
576
576
}
577
577
578
- if let Some ( tasks_from_turbo ) = raw_turbo. tasks {
579
- for ( task_name , task_def) in tasks_from_turbo {
580
- task_def
581
- . inputs
578
+ let mut tasks = raw_turbo. tasks . clone ( ) . unwrap_or_default ( ) ;
579
+ for ( _ , task_def) in tasks . iter_mut ( ) {
580
+ if let Some ( inputs ) = & task_def. inputs {
581
+ let updated_inputs = inputs
582
582
. iter ( )
583
- . map ( |glob| replace_turbo_root_token ( & mut task_def, path_to_repo_root) )
584
- . collect ( )
583
+ . map ( |glob| {
584
+ let updated_value =
585
+ replace_turbo_root_token_in_string ( & glob. value , path_to_repo_root) ;
586
+ Spanned :: new ( UnescapedString :: from ( updated_value) )
587
+ } )
588
+ . collect ( ) ;
589
+ task_def. inputs = Some ( updated_inputs) ;
585
590
}
586
591
}
587
592
@@ -611,7 +616,7 @@ impl TurboJson {
611
616
612
617
global_deps
613
618
} ,
614
- tasks : raw_turbo . tasks . unwrap_or_default ( ) ,
619
+ tasks,
615
620
// copy these over, we don't need any changes here.
616
621
extends : raw_turbo
617
622
. extends
@@ -783,27 +788,33 @@ fn gather_env_vars(
783
788
Ok ( ( ) )
784
789
}
785
790
791
+ fn replace_turbo_root_token_in_string (
792
+ input : & str ,
793
+ path_to_repo_root : & AnchoredSystemPath ,
794
+ ) -> String {
795
+ input. replacen ( TURBO_ROOT , path_to_repo_root. as_str ( ) , 1 )
796
+ }
797
+
786
798
fn replace_turbo_root_token (
787
799
task_definition : & mut TaskDefinition ,
788
800
path_to_repo_root : & AnchoredSystemPath ,
789
- ) {
790
- for input in task_definition. inputs . iter_mut ( ) {
791
- let _ = input. replacen ( TURBO_ROOT , path_to_repo_root. as_str ( ) , 1 ) ;
801
+ ) -> TaskDefinition {
802
+ let mut new_task = task_definition. clone ( ) ;
803
+
804
+ for input in & mut new_task. inputs {
805
+ * input = input. replacen ( TURBO_ROOT , path_to_repo_root. as_str ( ) , 1 ) ;
792
806
}
793
807
794
- for output in task_definition. outputs . validated_exclusions ( ) . iter_mut ( ) {
795
- let _ = output. iter ( ) . map ( |glob| {
796
- glob. as_str ( )
797
- . replacen ( TURBO_ROOT , path_to_repo_root. as_str ( ) , 1 )
798
- } ) ;
808
+ let outputs = & mut new_task. outputs ;
809
+ for output in & mut outputs. exclusions {
810
+ * output = output. replacen ( TURBO_ROOT , path_to_repo_root. as_str ( ) , 1 ) ;
799
811
}
800
812
801
- for output in task_definition. outputs . validated_inclusions ( ) . iter_mut ( ) {
802
- let _ = output. iter ( ) . map ( |glob| {
803
- glob. as_str ( )
804
- . replacen ( TURBO_ROOT , path_to_repo_root. as_str ( ) , 1 )
805
- } ) ;
813
+ for output in & mut outputs. inclusions {
814
+ * output = output. replacen ( TURBO_ROOT , path_to_repo_root. as_str ( ) , 1 ) ;
806
815
}
816
+
817
+ new_task
807
818
}
808
819
809
820
#[ cfg( test) ]
@@ -828,7 +839,7 @@ mod tests {
828
839
#[ test_case( "{}" , "empty boundaries" ) ]
829
840
#[ test_case( r#"{"tags": {} }"# , "empty tags" ) ]
830
841
#[ test_case(
831
- r#"{"tags": { "my-tag": { "dependencies": { "allow": ["my-package"] } } } } "# ,
842
+ r#"{"tags": { "my-tag": { "dependencies": { "allow": ["my-package"] } } }"# ,
832
843
"tags and dependencies"
833
844
) ]
834
845
#[ test_case(
0 commit comments