File tree Expand file tree Collapse file tree 2 files changed +18
-10
lines changed Expand file tree Collapse file tree 2 files changed +18
-10
lines changed Original file line number Diff line number Diff line change 1
1
use std:: collections:: { HashMap , HashSet } ;
2
2
use std:: convert:: identity;
3
- use std:: path:: PathBuf ;
4
3
use std:: string:: String ;
5
4
use std:: sync:: {
6
5
atomic:: { AtomicBool , Ordering } ,
@@ -404,10 +403,7 @@ async fn execute_task_with_watcher(
404
403
// Get inputs directly from the task
405
404
let inputs = if let Some ( execute) = task. task ( ) . as_execute ( ) {
406
405
if let Some ( inputs) = & execute. inputs {
407
- inputs
408
- . iter ( )
409
- . map ( |i| task. project ( ) . root ( ) . join ( i) )
410
- . collect :: < Vec < PathBuf > > ( )
406
+ inputs. clone ( )
411
407
} else {
412
408
Vec :: new ( )
413
409
}
@@ -469,8 +465,20 @@ async fn execute_task_with_watcher(
469
465
// Configure file watcher with debouncing
470
466
let debounce = Duration :: from_millis ( 700 ) ;
471
467
468
+ let root = if let Some ( cwd) = task
469
+ . task ( )
470
+ . as_execute ( )
471
+ . expect ( "Task should be an execute task" )
472
+ . cwd
473
+ . clone ( )
474
+ {
475
+ cwd
476
+ } else {
477
+ task. project ( ) . root ( ) . to_path_buf ( )
478
+ } ;
479
+
472
480
// Create the file watcher
473
- let mut watcher = FileWatcher :: new ( & cwd , & inputs, debounce)
481
+ let mut watcher = FileWatcher :: new ( & root , & inputs, debounce)
474
482
. await
475
483
. map_err ( |e| {
476
484
error ! ( "Failed to watch files: {}" , e) ;
Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ pub struct FileWatcher {
47
47
impl FileWatcher {
48
48
/// Creates a new file watcher
49
49
pub async fn new (
50
- cwd : & Path ,
50
+ root : & Path ,
51
51
patterns : & [ impl AsRef < Path > ] ,
52
52
debounce : Duration ,
53
53
) -> Result < Self , FileWatchError > {
@@ -69,16 +69,16 @@ impl FileWatcher {
69
69
let glob = Glob :: new ( & path_str) ?;
70
70
71
71
// Try to find existing files matching the pattern
72
- for entry in glob. walk ( cwd ) . flatten ( ) {
72
+ for entry in glob. walk ( root ) . flatten ( ) {
73
73
let path = entry. path ( ) . to_path_buf ( ) ;
74
74
// Convert to absolute path if it's relative
75
75
let path = if path. is_absolute ( ) {
76
76
path
77
77
} else {
78
- cwd . join ( path)
78
+ root . join ( path)
79
79
} ;
80
80
81
- debouncer. watch ( & path, RecursiveMode :: Recursive ) ?;
81
+ debouncer. watch ( & path, RecursiveMode :: NonRecursive ) ?;
82
82
}
83
83
}
84
84
You can’t perform that action at this time.
0 commit comments