fix: prevent infinite rebuild loops with custom output folders#492
Merged
fix: prevent infinite rebuild loops with custom output folders#492
Conversation
When using `honkit serve` with a custom output folder (not `_book`), files copied to the output folder were being detected by the watcher, causing a rebuild, which would copy files again, triggering another rebuild in an infinite loop. The fix passes the output folder to the watch function, which adds it to the ignored patterns list. This ensures that file changes in the output folder don't trigger unnecessary rebuilds. Fixes #491
On Windows, path.relative() returns paths with backslashes, but glob patterns require forward slashes. This ensures the output folder is correctly ignored on Windows.
Use chokidar's ready event and Promise-based waitForChange helper instead of arbitrary setTimeout delays. This makes tests faster and more reliable.
- Change watch() to accept a single options object instead of positional args - Rename 'dir' to 'watchDir' for clarity - Fix test flakiness by adding stabilization delay after ready event - Convert Windows backslashes to forward slashes in glob patterns
- Add normalizePath helper to handle path separator differences - Increase timeouts for Windows file system operations - Remove non-null assertions for type safety
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
honkit servewith custom output folderProblem
When using
honkit servewith a custom output folder (not_book), files copied to the output folder were being detected by the watcher, causing a rebuild, which would copy files again, triggering another rebuild in an infinite loop.Solutions
The fix passes the output folder to the watch function, which adds it to the ignored patterns list. This ensures that file changes in the output folder don't trigger unnecessary rebuilds.
Fixes #491