From f533fbb7fb35440a0a48394d504953efba6255aa Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Thu, 11 Jan 2024 18:39:38 +0100 Subject: [PATCH] chore: watch .env files (and then reload) (#403) --- src/extension.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/extension.ts b/src/extension.ts index 0f11c192d..d3999d786 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -204,8 +204,12 @@ export class Extension { ]; await this._rebuildModel(false); - const fileSystemWatcher = this._vscode.workspace.createFileSystemWatcher('**/*playwright*.config.{ts,js,mjs}'); - this._disposables.push(fileSystemWatcher); + const fileSystemWatchers = [ + // Glob parser does not supported nested group, hence multiple watchers. + this._vscode.workspace.createFileSystemWatcher('**/*playwright*.config.{ts,js,mjs}'), + this._vscode.workspace.createFileSystemWatcher('**/*.env*'), + ]; + this._disposables.push(...fileSystemWatchers); const rebuildModelForConfig = (uri: vscodeTypes.Uri) => { // TODO: parse .gitignore if (uri.fsPath.includes('node_modules')) @@ -214,9 +218,9 @@ export class Extension { return; this._rebuildModel(false); }; - fileSystemWatcher.onDidChange(rebuildModelForConfig); - fileSystemWatcher.onDidCreate(rebuildModelForConfig); - fileSystemWatcher.onDidDelete(rebuildModelForConfig); + fileSystemWatchers.map(w => w.onDidChange(rebuildModelForConfig)); + fileSystemWatchers.map(w => w.onDidCreate(rebuildModelForConfig)); + fileSystemWatchers.map(w => w.onDidDelete(rebuildModelForConfig)); context.subscriptions.push(this); }