From de50108ddb1f135330d2fc115c638f9ef01cc81b Mon Sep 17 00:00:00 2001 From: Jordan Ribbink Date: Wed, 15 Nov 2023 08:19:13 -0800 Subject: [PATCH] fix tests --- extension/src/server/flow-config.ts | 34 +++++++++++++++++------------ 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/extension/src/server/flow-config.ts b/extension/src/server/flow-config.ts index 8b69f59e..ba46e57f 100644 --- a/extension/src/server/flow-config.ts +++ b/extension/src/server/flow-config.ts @@ -195,24 +195,30 @@ export class FlowConfig implements Disposable { // If custom config path is set, watch that file // Otherwise watch for flow.json in workspace - const watchPath = this.#configPath$.value.isCustom && this.configPath != null ? this.configPath : '**/flow.json' + let watchPaths = this.#configPath$.value.isCustom && this.#configPath$.value.path != null ? [this.#configPath$.value.path] : null + if (watchPaths == null) { + // Watch all possible flow.json files in each workspace folder + watchPaths = workspace.workspaceFolders?.map(folder => path.resolve(folder.uri.fsPath, './flow.json')) ?? [] + } - // Watch for changes to config file - // If it does not exist, wait for flow.json to be created - configWatcher = workspace.createFileSystemWatcher(watchPath) + watchPaths.forEach(watchPath => { + // Watch for changes to config file + // If it does not exist, wait for flow.json to be created + configWatcher = workspace.createFileSystemWatcher(watchPath) - const configPathChangeHandler = (): void => { - void this.reloadConfigPath() - } - const configModifyHandler = (file: Uri): void => { - if (this.configPath != null && pathsAreEqual(file.fsPath, this.configPath)) { - this.#fileModified$.next() + const configPathChangeHandler = (): void => { + void this.reloadConfigPath() + } + const configModifyHandler = (file: Uri): void => { + if (this.configPath != null && pathsAreEqual(file.fsPath, this.configPath)) { + this.#fileModified$.next() + } } - } - configWatcher.onDidCreate(configPathChangeHandler) - configWatcher.onDidDelete(configPathChangeHandler) - configWatcher.onDidChange(configModifyHandler) + configWatcher.onDidCreate(configPathChangeHandler) + configWatcher.onDidDelete(configPathChangeHandler) + configWatcher.onDidChange(configModifyHandler) + }) } // Bind initial watcher