@@ -211,8 +211,8 @@ export class BoardManager {
211
211
this . parsePackageIndex ( JSON . parse ( packageContent ) ) ;
212
212
}
213
213
214
- this . loadInstalledPlatforms ( ) ;
215
214
this . loadDefaultPlatforms ( ) ;
215
+ this . loadInstalledPlatforms ( ) ;
216
216
217
217
this . loadInstalledBoards ( ) ;
218
218
this . updateStatusBar ( ) ;
@@ -280,18 +280,10 @@ export class BoardManager {
280
280
281
281
private loadDefaultPlatforms ( ) {
282
282
// Default arduino package information:
283
- const arduinoPath = this . _settings . arduinoPath ;
284
283
const packageName = "arduino" ;
285
284
const archName = "avr" ;
286
- let defaultPlatformPath = path . join ( arduinoPath , "hardware" ) ;
287
- const platform = os . platform ( ) ;
288
- if ( platform === "darwin" ) {
289
- defaultPlatformPath = path . join ( arduinoPath , "Arduino.app/Contents/Java/hardware" ) ;
290
- } else if ( platform === "linux" ) {
291
- // TODO Check default platform path at linux.
292
- }
293
285
try {
294
- let packageBundled = fs . readFileSync ( path . join ( defaultPlatformPath , "package_index_bundled.json" ) , "utf8" ) ;
286
+ let packageBundled = fs . readFileSync ( path . join ( this . _settings . defaultPackagePath , "package_index_bundled.json" ) , "utf8" ) ;
295
287
if ( ! packageBundled ) {
296
288
return ;
297
289
}
@@ -315,7 +307,7 @@ export class BoardManager {
315
307
return ;
316
308
} else {
317
309
filteredPlat . installedVersion = v ;
318
- filteredPlat . rootBoardPath = path . join ( defaultPlatformPath , "arduino/ avr" ) ;
310
+ filteredPlat . rootBoardPath = path . join ( this . _settings . defaultPackagePath , "arduino" , " avr") ;
319
311
this . installedPlatforms . push ( filteredPlat ) ;
320
312
}
321
313
}
@@ -351,11 +343,11 @@ export class BoardManager {
351
343
352
344
private loadInstalledPlatforms ( ) : void {
353
345
this . _installedPlatforms = [ ] ;
354
- let rootPacakgesPath = path . join ( path . join ( this . _settings . packagePath , "packages" ) ) ;
355
- if ( ! util . directoryExistsSync ( rootPacakgesPath ) ) {
346
+ let rootPackagePath = path . join ( path . join ( this . _settings . packagePath , "packages" ) ) ;
347
+ if ( ! util . directoryExistsSync ( rootPackagePath ) ) {
356
348
return ;
357
349
}
358
- const dirs = util . filterJunk ( fs . readdirSync ( rootPacakgesPath ) ) ; // in Mac, filter .DS_Store file.
350
+ const dirs = util . filterJunk ( util . readdirSync ( rootPackagePath , true ) ) ; // in Mac, filter .DS_Store file.
359
351
dirs . forEach ( ( packageName ) => {
360
352
let archPath = path . join ( this . _settings . packagePath , "packages" , packageName , "hardware" ) ;
361
353
if ( ! util . directoryExistsSync ( archPath ) ) {
@@ -369,6 +361,7 @@ export class BoardManager {
369
361
let allVersion = util . filterJunk ( fs . readdirSync ( path . join ( archPath , architecture ) ) ) ;
370
362
let existingPlatform = this . _platforms . find ( ( _plat ) => _plat . package . name === packageName && _plat . architecture === architecture ) ;
371
363
if ( existingPlatform && allVersion && allVersion . length ) {
364
+ existingPlatform . defaultPlatform = false ;
372
365
existingPlatform . installedVersion = allVersion [ 0 ] ;
373
366
existingPlatform . rootBoardPath = path . join ( archPath , architecture , allVersion [ 0 ] ) ;
374
367
this . _installedPlatforms . push ( existingPlatform ) ;
@@ -378,7 +371,6 @@ export class BoardManager {
378
371
}
379
372
380
373
private loadInstalledBoards ( ) : void {
381
- // let boards: Map<string, IBoard> = new Map<string, IBoard>();
382
374
this . _boards = new Map < string , IBoard > ( ) ;
383
375
this . installedPlatforms . forEach ( ( plat ) => {
384
376
let dir = plat . rootBoardPath ;
0 commit comments