fix(tswatch.classes.watcher): Convert directory watch paths to glob patterns for smartwatch compatibility

This commit is contained in:
2025-12-04 08:30:05 +00:00
parent d6f3381e71
commit ad41fe876d
4 changed files with 13 additions and 2 deletions

View File

@@ -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.'
}

View File

@@ -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(() => {