@@ -13,6 +13,14 @@ import { invalidateHoverScriptsCache, NpmScriptHoverProvider } from './scriptHov
13
13
14
14
let treeDataProvider : NpmScriptsTreeDataProvider | undefined ;
15
15
16
+ function invalidateScriptCaches ( ) {
17
+ invalidateHoverScriptsCache ( ) ;
18
+ invalidateTasksCache ( ) ;
19
+ if ( treeDataProvider ) {
20
+ treeDataProvider . refresh ( ) ;
21
+ }
22
+ }
23
+
16
24
export async function activate ( context : vscode . ExtensionContext ) : Promise < void > {
17
25
configureHttpRequest ( ) ;
18
26
context . subscriptions . push ( vscode . workspace . onDidChangeConfiguration ( e => {
@@ -45,6 +53,10 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
45
53
46
54
context . subscriptions . push ( vscode . commands . registerCommand ( 'npm.runSelectedScript' , runSelectedScript ) ) ;
47
55
context . subscriptions . push ( vscode . commands . registerCommand ( 'npm.runScriptFromFolder' , selectAndRunScriptFromFolder ) ) ;
56
+ context . subscriptions . push ( vscode . commands . registerCommand ( 'npm.refresh' , ( ) => {
57
+ invalidateScriptCaches ( ) ;
58
+ } ) ) ;
59
+
48
60
}
49
61
50
62
function canRunNpmInCurrentWorkspace ( ) {
@@ -55,15 +67,6 @@ function canRunNpmInCurrentWorkspace() {
55
67
}
56
68
57
69
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
-
67
70
if ( vscode . workspace . workspaceFolders ) {
68
71
let watcher = vscode . workspace . createFileSystemWatcher ( '**/package.json' ) ;
69
72
watcher . onDidChange ( ( _e ) => invalidateScriptCaches ( ) ) ;
0 commit comments