@@ -6,6 +6,7 @@ import * as Uuid from "uuid/v4";
6
6
import * as vscode from "vscode" ;
7
7
8
8
import { ArduinoContentProvider } from "./arduino/arduinoContentProvider" ;
9
+ import { IBoard } from "./arduino/package" ;
9
10
import ArduinoActivator from "./arduinoActivator" ;
10
11
import ArduinoContext from "./arduinoContext" ;
11
12
import {
@@ -157,13 +158,28 @@ export async function activate(context: vscode.ExtensionContext) {
157
158
}
158
159
delete status . compile ;
159
160
}
160
- } ,
161
- ( ) => {
162
- return { board : ArduinoContext . boardManager . currentBoard . name } ;
163
- } ) ;
161
+ } , ( ) => {
162
+ return { board : ArduinoContext . boardManager . currentBoard . name } ;
163
+ } ) ;
164
164
165
165
registerArduinoCommand ( "arduino.addLibPath" , ( path ) => ArduinoContext . arduinoApp . addLibPath ( path ) ) ;
166
166
registerArduinoCommand ( "arduino.openExample" , ( path ) => ArduinoContext . arduinoApp . openExample ( path ) ) ;
167
+ registerArduinoCommand ( "arduino.installBoard" , async ( packageName , arch , version : string = "" ) => {
168
+ let installed = false ;
169
+ const installedBoards = ArduinoContext . boardManager . installedBoards ;
170
+ installedBoards . forEach ( ( board : IBoard , key : string ) => {
171
+ if ( packageName === board . platform . package . name &&
172
+ arch === board . platform . architecture &&
173
+ ( ! version || version === board . platform . installedVersion ) ) {
174
+ installed = true ;
175
+ }
176
+ } ) ;
177
+
178
+ if ( ! installed ) {
179
+ await ArduinoContext . arduinoApp . installBoard ( packageName , arch , version ) ;
180
+ }
181
+ return ;
182
+ } ) ;
167
183
168
184
// serial monitor commands
169
185
const serialMonitor = SerialMonitor . getInstance ( ) ;
0 commit comments