@@ -7,6 +7,7 @@ use std::{
77 collections:: { BTreeMap , BTreeSet } ,
88 ffi:: OsStr ,
99 future:: Future ,
10+ iter:: once,
1011 sync:: Arc ,
1112} ;
1213
@@ -170,10 +171,23 @@ impl ResolvedTask {
170171 fingerprint_ignores : Option < Vec < Str > > ,
171172 ) -> Result < Self , Error > {
172173 let ResolveCommandResult { bin_path, envs } = command_result;
174+ // pnpm/npm/yarn doesn't contains separator in the bin path
175+ // JavaScript entry like node_modules/oxc/bin/oxlint does have separator
176+ #[ cfg( unix) ]
177+ let is_node_command = bin_path. contains ( '/' ) ;
178+ #[ cfg( windows) ]
179+ let is_node_command = bin_path. contains ( '\\' ) ;
180+
181+ let args_str = args. clone ( ) . map ( |arg| arg. as_ref ( ) . into ( ) ) ;
182+
173183 let builtin_task = TaskCommand :: Parsed ( TaskParsedCommand {
174- args : args. clone ( ) . map ( |arg| arg. as_ref ( ) . into ( ) ) . collect ( ) ,
184+ args : if is_node_command {
185+ once ( bin_path. as_str ( ) . into ( ) ) . chain ( args_str) . collect ( )
186+ } else {
187+ args_str. collect ( )
188+ } ,
175189 envs : envs. into_iter ( ) . map ( |( k, v) | ( k. into ( ) , v. into ( ) ) ) . collect ( ) ,
176- program : bin_path. into ( ) ,
190+ program : if is_node_command { "node" . into ( ) } else { bin_path. into ( ) } ,
177191 } ) ;
178192 let mut task_config: TaskConfig = builtin_task. clone ( ) . into ( ) ;
179193 task_config. set_fingerprint_ignores ( fingerprint_ignores. clone ( ) ) ;
0 commit comments