@@ -20,10 +20,17 @@ use vite_task::{
2020#[ derive( Debug , Subcommand ) ]
2121pub enum CustomTaskSubcommand {
2222 /// oxlint
23+ #[ clap( disable_help_flag = true ) ]
2324 Lint {
2425 #[ clap( allow_hyphen_values = true , trailing_var_arg = true ) ]
2526 args : Vec < Str > ,
2627 } ,
28+ /// vitest
29+ #[ clap( disable_help_flag = true ) ]
30+ Test {
31+ #[ clap( allow_hyphen_values = true , trailing_var_arg = true ) ]
32+ args : Vec < Str > ,
33+ } ,
2734 /// Test command for testing additional_envs feature
2835 EnvTest {
2936 /// Environment variable name
@@ -72,21 +79,30 @@ impl vite_task::TaskSynthesizer<CustomTaskSubcommand> for TaskSynthesizer {
7279 async fn synthesize_task (
7380 & mut self ,
7481 subcommand : CustomTaskSubcommand ,
75-
7682 envs : & Arc < HashMap < Arc < OsStr > , Arc < OsStr > > > ,
7783 cwd : & Arc < AbsolutePath > ,
7884 ) -> anyhow:: Result < SyntheticPlanRequest > {
85+ let synthesize_node_modules_bin_task = |subcommand_name : & str ,
86+ executable_name : & str ,
87+ args : Vec < Str > |
88+ -> anyhow:: Result < SyntheticPlanRequest > {
89+ let direct_execution_cache_key: Arc < [ Str ] > =
90+ iter:: once ( Str :: from ( subcommand_name) ) . chain ( args. iter ( ) . cloned ( ) ) . collect ( ) ;
91+ Ok ( SyntheticPlanRequest {
92+ program : find_executable ( get_path_env ( envs) , & * cwd, executable_name) ?,
93+ args : args. into ( ) ,
94+ task_options : Default :: default ( ) ,
95+ direct_execution_cache_key,
96+ envs : Arc :: clone ( envs) ,
97+ } )
98+ } ;
99+
79100 match subcommand {
80101 CustomTaskSubcommand :: Lint { args } => {
81- let direct_execution_cache_key: Arc < [ Str ] > =
82- iter:: once ( Str :: from ( "lint" ) ) . chain ( args. iter ( ) . cloned ( ) ) . collect ( ) ;
83- Ok ( SyntheticPlanRequest {
84- program : find_executable ( get_path_env ( envs) , & * cwd, "oxlint" ) ?,
85- args : args. into ( ) ,
86- task_options : Default :: default ( ) ,
87- direct_execution_cache_key,
88- envs : Arc :: clone ( envs) ,
89- } )
102+ synthesize_node_modules_bin_task ( "lint" , "oxlint" , args)
103+ }
104+ CustomTaskSubcommand :: Test { args } => {
105+ synthesize_node_modules_bin_task ( "test" , "vitest" , args)
90106 }
91107 CustomTaskSubcommand :: EnvTest { name, value } => {
92108 let direct_execution_cache_key: Arc < [ Str ] > =
0 commit comments