-
-
Notifications
You must be signed in to change notification settings - Fork 3k
fix: watching files outside cwd #5375
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Draft until:
|
@mochajs/maintenance-crew would appreciate your insights here, looks like this was a recently-introduced bug but I'm certainly no expert :) |
I'm no expert on this either but it looks sensible as a fix |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR restores the original watched path logic so that file patterns specified via --watch-files
can include files outside the current working directory.
- Reverts the hardcoded
'.'
watch path back to the user-providedwatchFiles
patterns. - Fixes issue 🐛 Bug: watching files outside of CWD is broken #5355 by enabling correct watching of external directories.
Comments suppressed due to low confidence (2)
lib/cli/watch-run.js:210
- Add or update tests to ensure that files outside the current working directory are being watched correctly, verifying the behavior introduced by this change.
const watcher = chokidar.watch(watchFiles, {
lib/cli/watch-run.js:210
- [nitpick] Ensure that
watchFiles
is normalized to a string or array of strings accepted by chokidar; if it's a single glob string, consider wrapping it in an array for consistent behavior.
const watcher = chokidar.watch(watchFiles, {
@@ -207,7 +207,7 @@ const createWatcher = ( | |||
const tracker = new GlobFilesTracker(watchFiles, watchIgnore); | |||
tracker.regenerate(); | |||
|
|||
const watcher = chokidar.watch('.', { | |||
const watcher = chokidar.watch(watchFiles, { | |||
ignoreInitial: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider forwarding the watchIgnore
patterns to chokidar.watch
via the ignored
option to prevent watching ignored files at all, improving efficiency.
ignoreInitial: true | |
ignoreInitial: true, | |
ignored: watchIgnore |
Copilot uses AI. Check for mistakes.
PR Checklist
status: accepting prs
(note that I was the one that added that tag!)Overview
In #5256 we changed the watched path from
watchFiles
to.
(cwd). Nobody commented on this, and it broke this behavior. Reverting that line fixes the reported issue in the provided repro