提交 66c63c5d 编写于 作者: A Alex Ross

Update npm tasks when npm refresh is run

Fixes #106780
上级 00a03f57
...@@ -13,6 +13,14 @@ import { invalidateHoverScriptsCache, NpmScriptHoverProvider } from './scriptHov ...@@ -13,6 +13,14 @@ import { invalidateHoverScriptsCache, NpmScriptHoverProvider } from './scriptHov
let treeDataProvider: NpmScriptsTreeDataProvider | undefined; let treeDataProvider: NpmScriptsTreeDataProvider | undefined;
function invalidateScriptCaches() {
invalidateHoverScriptsCache();
invalidateTasksCache();
if (treeDataProvider) {
treeDataProvider.refresh();
}
}
export async function activate(context: vscode.ExtensionContext): Promise<void> { export async function activate(context: vscode.ExtensionContext): Promise<void> {
configureHttpRequest(); configureHttpRequest();
context.subscriptions.push(vscode.workspace.onDidChangeConfiguration(e => { context.subscriptions.push(vscode.workspace.onDidChangeConfiguration(e => {
...@@ -45,6 +53,10 @@ export async function activate(context: vscode.ExtensionContext): Promise<void> ...@@ -45,6 +53,10 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
context.subscriptions.push(vscode.commands.registerCommand('npm.runSelectedScript', runSelectedScript)); context.subscriptions.push(vscode.commands.registerCommand('npm.runSelectedScript', runSelectedScript));
context.subscriptions.push(vscode.commands.registerCommand('npm.runScriptFromFolder', selectAndRunScriptFromFolder)); context.subscriptions.push(vscode.commands.registerCommand('npm.runScriptFromFolder', selectAndRunScriptFromFolder));
context.subscriptions.push(vscode.commands.registerCommand('npm.refresh', () => {
invalidateScriptCaches();
}));
} }
function canRunNpmInCurrentWorkspace() { function canRunNpmInCurrentWorkspace() {
...@@ -55,15 +67,6 @@ function canRunNpmInCurrentWorkspace() { ...@@ -55,15 +67,6 @@ function canRunNpmInCurrentWorkspace() {
} }
function registerTaskProvider(context: vscode.ExtensionContext): vscode.Disposable | undefined { function registerTaskProvider(context: vscode.ExtensionContext): vscode.Disposable | undefined {
function invalidateScriptCaches() {
invalidateHoverScriptsCache();
invalidateTasksCache();
if (treeDataProvider) {
treeDataProvider.refresh();
}
}
if (vscode.workspace.workspaceFolders) { if (vscode.workspace.workspaceFolders) {
let watcher = vscode.workspace.createFileSystemWatcher('**/package.json'); let watcher = vscode.workspace.createFileSystemWatcher('**/package.json');
watcher.onDidChange((_e) => invalidateScriptCaches()); watcher.onDidChange((_e) => invalidateScriptCaches());
......
...@@ -129,7 +129,6 @@ export class NpmScriptsTreeDataProvider implements TreeDataProvider<TreeItem> { ...@@ -129,7 +129,6 @@ export class NpmScriptsTreeDataProvider implements TreeDataProvider<TreeItem> {
subscriptions.push(commands.registerCommand('npm.runScript', this.runScript, this)); subscriptions.push(commands.registerCommand('npm.runScript', this.runScript, this));
subscriptions.push(commands.registerCommand('npm.debugScript', this.debugScript, this)); subscriptions.push(commands.registerCommand('npm.debugScript', this.debugScript, this));
subscriptions.push(commands.registerCommand('npm.openScript', this.openScript, this)); subscriptions.push(commands.registerCommand('npm.openScript', this.openScript, this));
subscriptions.push(commands.registerCommand('npm.refresh', this.refresh, this));
subscriptions.push(commands.registerCommand('npm.runInstall', this.runInstall, this)); subscriptions.push(commands.registerCommand('npm.runInstall', this.runInstall, this));
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册