Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jribbink committed Nov 15, 2023
1 parent d554c5d commit de50108
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions extension/src/server/flow-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit de50108

Please sign in to comment.