1
1
import * as fs from "fs" ;
2
2
import * as path from "path" ;
3
3
import * as vscode from "vscode" ;
4
- import * as util from "../common/util" ;
5
4
import * as constants from "../common/constants" ;
5
+ import * as util from "../common/util" ;
6
6
import { DeviceContext } from "../deviceContext" ;
7
7
import { ArduinoApp } from "./arduino" ;
8
8
import { IArduinoSettings } from "./arduinoSettings" ;
@@ -14,7 +14,7 @@ export class ProgrammerManager {
14
14
private _currentProgrammerName : string ;
15
15
16
16
private _programmerStatusBar : vscode . StatusBarItem ;
17
-
17
+
18
18
private _programmers : Map < string , string > ;
19
19
20
20
constructor ( private _settings : IArduinoSettings , private _arduinoApp : ArduinoApp ) {
@@ -29,8 +29,7 @@ export class ProgrammerManager {
29
29
return this . _programmers . get ( this . _currentProgrammerName ) ;
30
30
}
31
31
32
- public loadConfig ( )
33
- {
32
+ public loadConfig ( ) {
34
33
this . loadProgrammers ( ) ;
35
34
36
35
this . updateStatusBar ( ) ;
@@ -42,14 +41,15 @@ export class ProgrammerManager {
42
41
}
43
42
44
43
public async selectProgrammer ( ) {
45
- const chosen : string | undefined = await vscode . window . showQuickPick ( Array . from ( this . _programmers . keys ( ) ) , { placeHolder : "Select programmer" } ) ;
44
+ const chosen : string | undefined = await vscode . window . showQuickPick ( Array . from ( this . _programmers . keys ( ) ) ,
45
+ { placeHolder : "Select programmer" } ) ;
46
46
47
47
if ( ! chosen ) {
48
48
return ;
49
49
}
50
50
51
51
this . _currentProgrammerName = chosen ;
52
-
52
+
53
53
this . _programmerStatusBar . text = this . _currentProgrammerName ;
54
54
const dc = DeviceContext . getInstance ( ) ;
55
55
dc . programmer = this . _currentProgrammerName ;
@@ -60,15 +60,16 @@ export class ProgrammerManager {
60
60
const boardLineRegex = / ( [ ^ \. ] + ) \. ( \S + ) = ( .+ ) / ;
61
61
62
62
this . _arduinoApp . boardManager . platforms . forEach ( ( ( plat ) => {
63
- if ( plat . rootBoardPath === undefined )
63
+ if ( plat . rootBoardPath === undefined ) {
64
64
return ;
65
+ }
65
66
66
67
const programmmerFilePath = path . join ( plat . rootBoardPath , "programmers.txt" ) ;
67
68
68
69
if ( util . fileExistsSync ( programmmerFilePath ) ) {
69
70
const boardContent = fs . readFileSync ( programmmerFilePath , "utf8" ) ;
70
71
const lines = boardContent . split ( / [ \r | \r \n | \n ] / ) ;
71
-
72
+
72
73
lines . forEach ( ( line ) => {
73
74
// Ignore comments.
74
75
if ( line . startsWith ( "#" ) ) {
@@ -77,9 +78,8 @@ export class ProgrammerManager {
77
78
78
79
const match = boardLineRegex . exec ( line ) ;
79
80
if ( match && match . length > 3 ) {
80
- if ( match [ 2 ] === "name" )
81
- {
82
- this . _programmers . set ( match [ 3 ] , match [ 1 ] )
81
+ if ( match [ 2 ] === "name" ) {
82
+ this . _programmers . set ( match [ 3 ] , match [ 1 ] ) ;
83
83
}
84
84
}
85
85
} ) ;
@@ -88,8 +88,7 @@ export class ProgrammerManager {
88
88
}
89
89
90
90
private updateStatusBar ( show : boolean = true ) : void {
91
- if ( show )
92
- {
91
+ if ( show ) {
93
92
this . _programmerStatusBar . show ( ) ;
94
93
const dc = DeviceContext . getInstance ( ) ;
95
94
const selectedProgrammer = this . _programmers . get ( dc . programmer ) ;
0 commit comments