Skip to content

Commit 66c63c5

Browse files
committed
Update npm tasks when npm refresh is run
Fixes microsoft#106780
1 parent 00a03f5 commit 66c63c5

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

extensions/npm/src/npmMain.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ import { invalidateHoverScriptsCache, NpmScriptHoverProvider } from './scriptHov
1313

1414
let treeDataProvider: NpmScriptsTreeDataProvider | undefined;
1515

16+
function invalidateScriptCaches() {
17+
invalidateHoverScriptsCache();
18+
invalidateTasksCache();
19+
if (treeDataProvider) {
20+
treeDataProvider.refresh();
21+
}
22+
}
23+
1624
export async function activate(context: vscode.ExtensionContext): Promise<void> {
1725
configureHttpRequest();
1826
context.subscriptions.push(vscode.workspace.onDidChangeConfiguration(e => {
@@ -45,6 +53,10 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
4553

4654
context.subscriptions.push(vscode.commands.registerCommand('npm.runSelectedScript', runSelectedScript));
4755
context.subscriptions.push(vscode.commands.registerCommand('npm.runScriptFromFolder', selectAndRunScriptFromFolder));
56+
context.subscriptions.push(vscode.commands.registerCommand('npm.refresh', () => {
57+
invalidateScriptCaches();
58+
}));
59+
4860
}
4961

5062
function canRunNpmInCurrentWorkspace() {
@@ -55,15 +67,6 @@ function canRunNpmInCurrentWorkspace() {
5567
}
5668

5769
function registerTaskProvider(context: vscode.ExtensionContext): vscode.Disposable | undefined {
58-
59-
function invalidateScriptCaches() {
60-
invalidateHoverScriptsCache();
61-
invalidateTasksCache();
62-
if (treeDataProvider) {
63-
treeDataProvider.refresh();
64-
}
65-
}
66-
6770
if (vscode.workspace.workspaceFolders) {
6871
let watcher = vscode.workspace.createFileSystemWatcher('**/package.json');
6972
watcher.onDidChange((_e) => invalidateScriptCaches());

extensions/npm/src/npmView.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ export class NpmScriptsTreeDataProvider implements TreeDataProvider<TreeItem> {
129129
subscriptions.push(commands.registerCommand('npm.runScript', this.runScript, this));
130130
subscriptions.push(commands.registerCommand('npm.debugScript', this.debugScript, this));
131131
subscriptions.push(commands.registerCommand('npm.openScript', this.openScript, this));
132-
subscriptions.push(commands.registerCommand('npm.refresh', this.refresh, this));
133132
subscriptions.push(commands.registerCommand('npm.runInstall', this.runInstall, this));
134133
}
135134

0 commit comments

Comments
 (0)