fix(tswatch.classes.watcher): Convert directory watch paths to glob patterns for smartwatch compatibility
This commit is contained in:
@@ -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(() => {
|
||||
|
||||
Reference in New Issue
Block a user