Skip to content

Commit 032a083

Browse files
committed
fix: use the task root instead of cwd for findings globs
1 parent 56d45b3 commit 032a083

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

src/cli/watch.rs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use std::collections::{HashMap, HashSet};
22
use std::convert::identity;
3-
use std::path::PathBuf;
43
use std::string::String;
54
use std::sync::{
65
atomic::{AtomicBool, Ordering},
@@ -404,10 +403,7 @@ async fn execute_task_with_watcher(
404403
// Get inputs directly from the task
405404
let inputs = if let Some(execute) = task.task().as_execute() {
406405
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()
411407
} else {
412408
Vec::new()
413409
}
@@ -469,8 +465,20 @@ async fn execute_task_with_watcher(
469465
// Configure file watcher with debouncing
470466
let debounce = Duration::from_millis(700);
471467

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+
472480
// Create the file watcher
473-
let mut watcher = FileWatcher::new(&cwd, &inputs, debounce)
481+
let mut watcher = FileWatcher::new(&root, &inputs, debounce)
474482
.await
475483
.map_err(|e| {
476484
error!("Failed to watch files: {}", e);

src/task/watcher.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ pub struct FileWatcher {
4747
impl FileWatcher {
4848
/// Creates a new file watcher
4949
pub async fn new(
50-
cwd: &Path,
50+
root: &Path,
5151
patterns: &[impl AsRef<Path>],
5252
debounce: Duration,
5353
) -> Result<Self, FileWatchError> {
@@ -69,16 +69,16 @@ impl FileWatcher {
6969
let glob = Glob::new(&path_str)?;
7070

7171
// Try to find existing files matching the pattern
72-
for entry in glob.walk(cwd).flatten() {
72+
for entry in glob.walk(root).flatten() {
7373
let path = entry.path().to_path_buf();
7474
// Convert to absolute path if it's relative
7575
let path = if path.is_absolute() {
7676
path
7777
} else {
78-
cwd.join(path)
78+
root.join(path)
7979
};
8080

81-
debouncer.watch(&path, RecursiveMode::Recursive)?;
81+
debouncer.watch(&path, RecursiveMode::NonRecursive)?;
8282
}
8383
}
8484

0 commit comments

Comments
 (0)