You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* fix: watch mode using chokidar v4 (#5355)
Glob paths are no longer supported by chokidar starting at v4.
This update works around this by resolving `watchFiles` and `watchIgnore`
to valid paths and creating a list of matchers to determine if the files
should be allowed or ignored through the chokidar `ignored` match function.
This commit reverts changes from 8af0f1a
so that the watched file changes are not fixed to the current directory.
Additional note: when a `watchFile` path is removed while chokidar is
watching it, recreating the `watchFile` path does not trigger events
from chokidar to rerun the tests.
* refactor: fix watch mode using chokidar v4 (#5355)
This update fixes#5355 and refactors the previous watch mode fix attempt.
Instead of only filtering the paths in the chokidar `ignored` match
function, the chokidar `all` event handler now has a guard to ensure
that only file paths that match the allowed patterns from `watchFiles`
would trigger test reruns.
Doing this solves the issue where creating/deleting directories trigger
test reruns despite the watched path being a file (e.g., `**/*.xyz`)
as the allowed patterns would not match with just the directory paths.
* docs: fix jsdoc description for `normalizeGlob()`
* test: add tests for watch mode
- Test for watched files from outside the current working directory
- Test reruns with a thousand watched files
* test: fix test for multiple watched files
* test: remove test for multiple watched files
The test is dependent on how fast the machine could create 1000 watched
files, otherwise the test could fail due to a timeout error. Reducing
the number of watched files would make the test pass, but doing so would
make it more or less similar to already existing tests. At that point,
the test does not really test the limits of possibly huge projects with
thousands of watched files, so it has been removed instead.
* fix: update watch mode implementation
This update consolidates the function for retrieving the paths and globs
that will be used for the `watchFiles` and `watchIgnore` paths.
This should prevent path patterns from being duplicated and should now
also handle and watch paths under the provided glob paths.
Allowed and ignored file path results are now cached to a map (with a
size limit of 1000) to skip re-matching already matched file paths.
Additional tests for `watch.spec.js`:
- Test file and directory paths under `--watch-files` (no glob pattern)
- Test exact file path matches from `--watch-files`
- Test `--watch-files` starting and ending with a glob pattern
- Test `--watch-files` with a glob pattern in between
* Refactor, add debug
* Remove verbose debug
* Add debugs
* Remove castArray, capitalize Chokidar
* Replace for-of with Array.some
* Add test for false literal matches
* Document new test
* Remove unused function
* Remove createPathFilter and createPathMatcher from exports
* refactor: update watch mode
- Use array `flatMap` instead of `reduce` for glob path patterns
- Revert glob path matching check to a `for` loop (commit caca650)
- Update `MAX_CACHE_SIZE` from 1,000 to 10,000
- Update map cache to only delete the first key whenever the limit is reached
- Update debug logging and formatting
* chore: move watch mode callbacks and object typedefs to the new types.d.ts
* Apply suggestion from @JoshuaKGoldberg
Co-authored-by: Josh Goldberg ✨ <[email protected]>
---------
Co-authored-by: Josh Goldberg ✨ <[email protected]>
Co-authored-by: Mark Wiemer <[email protected]>
Co-authored-by: Mark Wiemer <[email protected]>
0 commit comments