Skip to content

fix: match build watch ignore by path segment - #925

Closed
AyobamiH wants to merge 1 commit into
fastify:mainfrom
AyobamiH:fix/717-watch-build-directory
Closed

AyobamiH wants to merge 1 commit into
fastify:mainfrom
AyobamiH:fix/717-watch-build-directory

Conversation

@AyobamiH

@AyobamiH AyobamiH commented Oct 5, 2026

Copy link
Copy Markdown

Fixes #717.

The watcher currently compiles the default ignore entries into a single regular expression. Because build is included as an unbounded alternative, it matches the substring anywhere in a watched path. This causes projects with names such as any-builder, as well as directories such as builders, to be ignored.

This change treats the literal build ignore entry as a path segment instead.

With this change:

  • build/app.js remains ignored
  • src/build/app.js remains ignored
  • Windows build directory paths remain ignored
  • any-builder/app.js is watched
  • builders/app.js is watched

The change is deliberately limited to the build token. Existing custom --ignore-watch expressions retain their current behaviour.

Regression coverage includes both POSIX and Windows path separators.

Checklist

  • run npm run test && npm run benchmark --if-present
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message and code follows the Developer's Certification of Origin and Code of Conduct

Documentation is not changed because this fixes the matching semantics of an existing documented default rather than changing the CLI interface or its documented default value.

Signed-off-by: Ayobami Haastrup <47716486+AyobamiH@users.noreply.github.com>
@AyobamiH

AyobamiH commented Oct 7, 2026

Copy link
Copy Markdown
Author

Validation update: the targeted watch regression passes cleanly on Node 24:

node suite-runner.js "test/watch.test.js"

tests 3
pass 3
fail 0
WATCH_EXIT=0

A full local npm run test was also attempted. It reached and passed this watch regression, then failed later in two unrelated generator tests because npm init -y inherited a deleted working directory (uv_cwd). The subsequent coverage failure was downstream of that interrupted suite.

This PR does not touch generate.js, generator workdir cleanup, or coverage configuration.

@zengks zengks mentioned this pull request Oct 27, 2026
4 tasks done
@SameRainbows

Copy link
Copy Markdown

Tested locally on Node 24 (Windows). All tests in test/watch.test.js pass cleanly with both POSIX and Windows backslash paths.

Bounding the build token with (?:^|[/\\\\])build(?:[/\\\\]|$) correctly stops projects located in directories like any-builder or builders from being accidentally ignored while preserving ignore behavior for actual build output folders.

Also, regarding the uv_cwd failure during full suite runs: that was caused by test/helper.test.js registering fs.promises.rm(testdir) ahead of process.chdir(cwd) in t.after. On Windows, deleting the active working directory throws EBUSY, which aborts teardown and leaves process.cwd() pointing at a missing directory for the generator tests that follow (addressed in #931).

@Tony133

Tony133 commented Nov 26, 2026

Copy link
Copy Markdown
Member

Thanks for the contribution! Issue #717 has been resolved by #938.

@Tony133 Tony133 closed this Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Watcher is not working on builders

3 participants