@@ -13,7 +13,7 @@ use crate::{
13
13
OutputLogsMode , RunArgs ,
14
14
} ,
15
15
config:: ConfigurationOptions ,
16
- run:: task_id:: TaskId ,
16
+ run:: task_id:: { TaskId , TaskName } ,
17
17
turbo_json:: { UIMode , CONFIG_FILE } ,
18
18
Args ,
19
19
} ;
@@ -258,7 +258,7 @@ impl<'a> TaskArgs<'a> {
258
258
&& self
259
259
. tasks
260
260
. iter ( )
261
- . any ( |task| task. as_str ( ) == task_id. task ( ) )
261
+ . any ( |task| TaskName :: from ( task. as_str ( ) ) . task ( ) == task_id. task ( ) )
262
262
{
263
263
Some ( self . pass_through_args )
264
264
} else {
@@ -550,12 +550,13 @@ mod test {
550
550
use turborepo_cache:: { CacheActions , CacheConfig , CacheOpts } ;
551
551
use turborepo_ui:: ColorConfig ;
552
552
553
- use super :: { APIClientOpts , RepoOpts , RunOpts } ;
553
+ use super :: { APIClientOpts , RepoOpts , RunOpts , TaskArgs } ;
554
554
use crate :: {
555
555
cli:: { Command , ContinueMode , DryRunMode , RunArgs } ,
556
556
commands:: CommandBase ,
557
557
config:: ConfigurationOptions ,
558
558
opts:: { Opts , RunCacheOpts , ScopeOpts } ,
559
+ run:: task_id:: TaskId ,
559
560
turbo_json:: { UIMode , CONFIG_FILE } ,
560
561
Args ,
561
562
} ;
@@ -876,4 +877,51 @@ mod test {
876
877
877
878
Ok ( ( ) )
878
879
}
880
+
881
+ #[ test_case(
882
+ vec![ "build" . to_string( ) ] ,
883
+ vec![ "passthrough" . to_string( ) ] ,
884
+ TaskId :: new( "web" , "build" ) ,
885
+ Some ( vec![ "passthrough" . to_string( ) ] ) ;
886
+ "single task"
887
+ ) ]
888
+ #[ test_case(
889
+ vec![ "lint" . to_string( ) , "build" . to_string( ) ] ,
890
+ vec![ "passthrough" . to_string( ) ] ,
891
+ TaskId :: new( "web" , "build" ) ,
892
+ Some ( vec![ "passthrough" . to_string( ) ] ) ;
893
+ "multiple tasks"
894
+ ) ]
895
+ #[ test_case(
896
+ vec![ "web#build" . to_string( ) ] ,
897
+ vec![ "passthrough" . to_string( ) ] ,
898
+ TaskId :: new( "web" , "build" ) ,
899
+ Some ( vec![ "passthrough" . to_string( ) ] ) ;
900
+ "task with package"
901
+ ) ]
902
+ #[ test_case(
903
+ vec![ "lint" . to_string( ) ] ,
904
+ vec![ ] ,
905
+ TaskId :: new( "ui" , "lint" ) ,
906
+ None ;
907
+ "no passthrough args"
908
+ ) ]
909
+ fn test_get_args_for_tasks (
910
+ tasks : Vec < String > ,
911
+ pass_through_args : Vec < String > ,
912
+ expected_task : TaskId < ' static > ,
913
+ expected_args : Option < Vec < String > > ,
914
+ ) -> Result < ( ) , anyhow:: Error > {
915
+ let task_opts = TaskArgs {
916
+ tasks : & tasks,
917
+ pass_through_args : & pass_through_args,
918
+ } ;
919
+
920
+ assert_eq ! (
921
+ task_opts. args_for_task( & expected_task) ,
922
+ expected_args. as_deref( )
923
+ ) ;
924
+
925
+ Ok ( ( ) )
926
+ }
879
927
}
0 commit comments