fix(watcher.node): Handle fs.watch close without spurious restarts; add tests and improve test runner

This commit is contained in:
2025-12-10 16:52:06 +00:00
parent 2f55f628f5
commit 4894253e48
9 changed files with 442 additions and 54 deletions

View File

@@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@push.rocks/smartwatch',
version: '6.2.0',
version: '6.2.1',
description: 'A cross-runtime file watcher with glob pattern support for Node.js, Deno, and Bun.'
}

View File

@@ -339,8 +339,9 @@ export class NodeWatcher implements IWatcher {
// Handle 'close' event - fs.watch can close without error
watcher.on('close', () => {
console.warn(`[smartwatch] FSWatcher closed unexpectedly for ${watchPath}`);
// Only log/restart if we didn't intentionally stop
if (this._isWatching) {
console.warn(`[smartwatch] FSWatcher closed unexpectedly for ${watchPath}`);
this.restartWatcher(watchPath, new Error('Watcher closed unexpectedly'));
}
});