Skip to content

Commit

Permalink
chore: watch .env files (and then reload) (#403)
Browse files Browse the repository at this point in the history
  • Loading branch information
mxschmitt authored Jan 11, 2024
1 parent f025947 commit f533fbb
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'))
Expand All @@ -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);
}

Expand Down

0 comments on commit f533fbb

Please sign in to comment.