@@ -11,7 +11,10 @@ import {
1111 WorkspaceFolder , commands , debug , window , workspace , Selection , TaskGroup
1212} from 'vscode' ;
1313import { visit , JSONVisitor } from 'jsonc-parser' ;
14- import { NpmTaskDefinition , getPackageJsonUriFromTask , getScripts , isWorkspaceFolder , getPackageManager , getTaskName } from './tasks' ;
14+ import {
15+ NpmTaskDefinition , getPackageJsonUriFromTask , getScripts ,
16+ isWorkspaceFolder , getPackageManager , getTaskName , createTask
17+ } from './tasks' ;
1518import * as nls from 'vscode-nls' ;
1619
1720const localize = nls . loadMessageBundle ( ) ;
@@ -133,6 +136,7 @@ export class NpmScriptsTreeDataProvider implements TreeDataProvider<TreeItem> {
133136 subscriptions . push ( commands . registerCommand ( 'npm.debugScript' , this . debugScript , this ) ) ;
134137 subscriptions . push ( commands . registerCommand ( 'npm.openScript' , this . openScript , this ) ) ;
135138 subscriptions . push ( commands . registerCommand ( 'npm.refresh' , this . refresh , this ) ) ;
139+ subscriptions . push ( commands . registerCommand ( 'npm.runInstall' , this . runInstall , this ) ) ;
136140 }
137141
138142 private scriptIsValid ( scripts : any , task : Task ) : boolean {
@@ -258,6 +262,19 @@ export class NpmScriptsTreeDataProvider implements TreeDataProvider<TreeItem> {
258262 return scriptOffset ;
259263
260264 }
265+
266+ private async runInstall ( selection : PackageJSON ) {
267+ let uri : Uri | undefined = undefined ;
268+ if ( selection instanceof PackageJSON ) {
269+ uri = selection . resourceUri ;
270+ }
271+ if ( ! uri ) {
272+ return ;
273+ }
274+ let task = createTask ( 'install' , 'install' , selection . folder . workspaceFolder , uri , [ ] ) ;
275+ workspace . executeTask ( task ) ;
276+ }
277+
261278 private async openScript ( selection : PackageJSON | NpmScript ) {
262279 let uri : Uri | undefined = undefined ;
263280 if ( selection instanceof PackageJSON ) {
0 commit comments