1111using Microsoft . NodejsTools . NpmUI ;
1212using Microsoft . VisualStudio ;
1313using Microsoft . VisualStudio . OLE . Interop ;
14- using Microsoft . VisualStudio . Shell ;
1514using Microsoft . VisualStudio . Workspace ;
1615using Microsoft . VisualStudio . Workspace . Debug ;
1716using Microsoft . VisualStudio . Workspace . VSIntegration . UI ;
1817using Microsoft . VisualStudioTools . Project ;
19- using ShellInterop = Microsoft . VisualStudio . Shell . Interop ;
2018
2119namespace Microsoft . NodejsTools . Workspace
2220{
@@ -80,24 +78,26 @@ public int Exec(List<WorkspaceVisualNodeBase> selection, Guid pguidCmdGroup, uin
8078 {
8179 this . outputPane . InitializeOutputPanes ( ) ;
8280
81+ var fileNode = ( ( IFileNode ) node ) . FullPath ;
82+
8383 switch ( nCmdID )
8484 {
8585 case PkgCmdId . cmdidWorkSpaceNpmInstallMissing :
86- ExecNpmInstallMissing ( ( IFileNode ) node ) ;
86+ ExecNpmInstallMissing ( fileNode ) ;
8787 return VSConstants . S_OK ;
8888
8989 case PkgCmdId . cmdidWorkSpaceNpmInstallNew :
90- ExecNpmInstallNew ( ( IFileNode ) node ) ;
90+ ExecNpmInstallNew ( fileNode ) ;
9191 return VSConstants . S_OK ;
9292
9393 case PkgCmdId . cmdidWorkSpaceNpmUpdate :
94- ExecNpmUpdate ( ( IFileNode ) node ) ;
94+ ExecNpmUpdate ( fileNode ) ;
9595 return VSConstants . S_OK ;
9696 }
9797
9898 if ( nCmdID >= PkgCmdId . cmdidWorkSpaceNpmDynamicScript && nCmdID < PkgCmdId . cmdidWorkSpaceNpmDynamicScriptMax )
9999 {
100- ExecDynamic ( ( IFileNode ) node , nCmdID ) ;
100+ ExecDynamic ( fileNode , nCmdID ) ;
101101 return VSConstants . S_OK ;
102102 }
103103 }
@@ -119,40 +119,39 @@ public int Exec(List<WorkspaceVisualNodeBase> selection, Guid pguidCmdGroup, uin
119119 // Note: all the Exec commands are async, this allows us to call them in a fire and forget
120120 // pattern, without blocking the UI or losing any logging
121121
122- private async void ExecNpmInstallMissing ( IFileNode node )
122+ private async void ExecNpmInstallMissing ( string filePath )
123123 {
124- using ( var npmController = this . CreateController ( node . FullPath ) )
124+ using ( var npmController = this . CreateController ( filePath ) )
125125 using ( var commander = npmController . CreateNpmCommander ( ) )
126126 {
127127 await commander . Install ( ) ;
128128 }
129129 }
130130
131- private void ExecNpmInstallNew ( IFileNode node )
131+ private void ExecNpmInstallNew ( string filePath )
132132 {
133- using ( var npmController = this . CreateController ( node . FullPath ) )
133+ using ( var npmController = this . CreateController ( filePath ) )
134134 using ( var npmWorker = new NpmWorker ( npmController ) )
135135 using ( var manager = new NpmPackageInstallWindow ( npmController , npmWorker ) )
136136 {
137137 manager . ShowModal ( ) ;
138138 }
139139 }
140140
141- private async void ExecNpmUpdate ( IFileNode node )
141+ private async void ExecNpmUpdate ( string filePath )
142142 {
143- using ( var npmController = this . CreateController ( node . FullPath ) )
143+ using ( var npmController = this . CreateController ( filePath ) )
144144 using ( var commander = npmController . CreateNpmCommander ( ) )
145145 {
146146 await commander . UpdatePackagesAsync ( ) ;
147147 }
148148 }
149149
150- private async void ExecDynamic ( IFileNode node , uint nCmdID )
150+ private async void ExecDynamic ( string filePath , uint nCmdID )
151151 {
152152 // Unfortunately the NpmController (and NpmCommander), used for the install and update commands
153153 // doesn't support running arbitrary scripts. And changing that is outside
154154 // the scope of these changes.
155- var filePath = node . FullPath ;
156155 if ( TryGetCommand ( nCmdID , filePath , out var commandName ) )
157156 {
158157 using ( var npmController = this . CreateController ( filePath ) )
@@ -174,7 +173,7 @@ private async void ExecDebugAsync(WorkspaceVisualNodeBase node)
174173 }
175174
176175 //invoke debuglaunchtargetprovider on this file
177- var fileContextActions = await node . Workspace . GetFileContextActionsAsync ( packageJson . Main , new [ ] { DebugLaunchActionContext . ContextTypeGuid } ) ;
176+ var fileContextActions = await workspace . GetFileContextActionsAsync ( packageJson . Main , new [ ] { DebugLaunchActionContext . ContextTypeGuid } ) ;
178177 if ( fileContextActions . Any ( ) )
179178 {
180179 // we requested a single context, so there should be a single grouping. Use the First action, since they're ordered by priority.
@@ -274,7 +273,8 @@ private static bool TryGetCommand(uint nCmdID, string filePath, out string comma
274273
275274 private INpmController CreateController ( string packageJsonPath )
276275 {
277- Debug . Assert ( Path . IsPathRooted ( packageJsonPath ) && PackageJsonFactory . IsPackageJsonFile ( packageJsonPath ) ) ;
276+ Debug . Assert ( Path . IsPathRooted ( packageJsonPath ) ) ;
277+ Debug . Assert ( PackageJsonFactory . IsPackageJsonFile ( packageJsonPath ) ) ;
278278
279279 var projectHome = Path . GetDirectoryName ( packageJsonPath ) ;
280280
0 commit comments