From ad41fe876d119ed5df093bc11c9fe4c958303ea8 Mon Sep 17 00:00:00 2001 From: Juergen Kunz Date: Thu, 4 Dec 2025 08:30:05 +0000 Subject: [PATCH] fix(tswatch.classes.watcher): Convert directory watch paths to glob patterns for smartwatch compatibility --- changelog.md | 6 ++++++ readme.hints.md | 1 + ts/00_commitinfo_data.ts | 2 +- ts/tswatch.classes.watcher.ts | 6 +++++- 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/changelog.md b/changelog.md index ff15eaf..6f29cd1 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,11 @@ # Changelog +## 2025-12-04 - 2.2.3 - fix(tswatch.classes.watcher) +Convert directory watch paths to glob patterns for smartwatch compatibility + +- Watcher: convert directory paths to recursive glob patterns before adding them to Smartwatch so directories are watched recursively (e.g. /path/to/dir/ -> /path/to/dir/**/*). +- Readme: added migration note explaining that directory paths are converted to glob patterns for smartwatch compatibility. + ## 2025-12-01 - 2.2.2 - fix(core) Replace smartchok/smartfile with smartwatch/smartfs, update watcher and plugins, and bump dependencies diff --git a/readme.hints.md b/readme.hints.md index 272ea32..c92b91a 100644 --- a/readme.hints.md +++ b/readme.hints.md @@ -48,3 +48,4 @@ - Replaced `@push.rocks/smartchok` with `@push.rocks/smartwatch` (v5.x) - Replaced `@push.rocks/smartfile` with `@push.rocks/smartfs` for directory listing - Class names: `Smartwatch` for file watching, `SmartFs` + `SmartFsProviderNode` for filesystem ops +- Directory paths are converted to glob patterns (`/path/to/dir/` → `/path/to/dir/**/*`) for smartwatch compatibility diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index cf3e036..b2e5391 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -3,6 +3,6 @@ */ export const commitinfo = { name: '@git.zone/tswatch', - version: '2.2.2', + version: '2.2.3', description: 'A development tool for automatically watching and re-compiling TypeScript projects upon detecting file changes, enhancing developer workflows.' } diff --git a/ts/tswatch.classes.watcher.ts b/ts/tswatch.classes.watcher.ts index 6ee2816..0f5b6b3 100644 --- a/ts/tswatch.classes.watcher.ts +++ b/ts/tswatch.classes.watcher.ts @@ -34,7 +34,11 @@ export class Watcher { logger.log('info', `trying to start watcher for ${this.options.filePathToWatch}`); await this.setupCleanup(); console.log(`Looking at ${this.options.filePathToWatch} for changes`); - this.smartwatchInstance.add([this.options.filePathToWatch]); // __dirname refers to the directory of this very file + // Convert directory path to glob pattern for smartwatch + const watchPath = this.options.filePathToWatch.endsWith('/') + ? `${this.options.filePathToWatch}**/*` + : `${this.options.filePathToWatch}/**/*`; + this.smartwatchInstance.add([watchPath]); await this.smartwatchInstance.start(); const changeObservable = await this.smartwatchInstance.getObservableFor('change'); changeObservable.subscribe(() => {