@@ -13,7 +13,7 @@ import * as constants from "../common/constants";
13
13
import * as util from "../common/util" ;
14
14
import * as Logger from "../logger/logger" ;
15
15
16
- import { DeviceContext , IDeviceContext } from "../deviceContext" ;
16
+ import { DeviceContext } from "../deviceContext" ;
17
17
import { IArduinoSettings } from "./arduinoSettings" ;
18
18
import { BoardManager } from "./boardManager" ;
19
19
import { ExampleManager } from "./exampleManager" ;
@@ -35,14 +35,14 @@ export class ArduinoApp {
35
35
private _exampleManager : ExampleManager ;
36
36
37
37
/**
38
- * @param {IArduinoSettings } ArduinoSetting object.
38
+ * @param {IArduinoSettings } _settings ArduinoSetting object.
39
39
*/
40
40
constructor ( private _settings : IArduinoSettings ) {
41
41
}
42
42
43
43
/**
44
44
* Need refresh Arduino IDE's setting when starting up.
45
- * @param {boolean } force - Whether force initialzie the arduino
45
+ * @param {boolean } force - Whether force initialize the arduino
46
46
*/
47
47
public async initialize ( force : boolean = false ) {
48
48
if ( ! util . fileExistsSync ( this . _settings . preferencePath ) ) {
@@ -91,8 +91,8 @@ export class ArduinoApp {
91
91
}
92
92
93
93
public async upload ( ) {
94
- const dc = DeviceContext . getIntance ( ) ;
95
- const boardDescriptor = this . getBoardBuildString ( dc ) ;
94
+ const dc = DeviceContext . getInstance ( ) ;
95
+ const boardDescriptor = this . getBoardBuildString ( ) ;
96
96
if ( ! boardDescriptor ) {
97
97
return ;
98
98
}
@@ -113,17 +113,17 @@ export class ArduinoApp {
113
113
arduinoChannel . show ( ) ;
114
114
arduinoChannel . start ( `Upload sketch - ${ dc . sketch } ` ) ;
115
115
116
- const serialMonitor = SerialMonitor . getIntance ( ) ;
116
+ const serialMonitor = SerialMonitor . getInstance ( ) ;
117
117
118
118
const needRestore = await serialMonitor . closeSerialMonitor ( dc . port ) ;
119
119
await vscode . workspace . saveAll ( false ) ;
120
120
121
121
const appPath = path . join ( vscode . workspace . rootPath , dc . sketch ) ;
122
122
const args = [ "--upload" , "--board" , boardDescriptor , "--port" , dc . port , appPath ] ;
123
- if ( VscodeSettings . getIntance ( ) . logLevel === "verbose" ) {
123
+ if ( VscodeSettings . getInstance ( ) . logLevel === "verbose" ) {
124
124
args . push ( "--verbose" ) ;
125
125
}
126
- await util . spawn ( this . _settings . commandPath , arduinoChannel . channel , args ) . then ( async ( result ) => {
126
+ await util . spawn ( this . _settings . commandPath , arduinoChannel . channel , args ) . then ( async ( ) => {
127
127
if ( needRestore ) {
128
128
await serialMonitor . openSerialMonitor ( ) ;
129
129
}
@@ -134,8 +134,8 @@ export class ArduinoApp {
134
134
}
135
135
136
136
public async verify ( output : string = "" ) {
137
- const dc = DeviceContext . getIntance ( ) ;
138
- const boardDescriptor = this . getBoardBuildString ( dc ) ;
137
+ const dc = DeviceContext . getInstance ( ) ;
138
+ const boardDescriptor = this . getBoardBuildString ( ) ;
139
139
if ( ! boardDescriptor ) {
140
140
return ;
141
141
}
@@ -154,18 +154,18 @@ export class ArduinoApp {
154
154
arduinoChannel . start ( `Verify sketch - ${ dc . sketch } ` ) ;
155
155
const appPath = path . join ( vscode . workspace . rootPath , dc . sketch ) ;
156
156
const args = [ "--verify" , "--board" , boardDescriptor , appPath ] ;
157
- if ( VscodeSettings . getIntance ( ) . logLevel === "verbose" ) {
157
+ if ( VscodeSettings . getInstance ( ) . logLevel === "verbose" ) {
158
158
args . push ( "--verbose" ) ;
159
159
}
160
- if ( output ) {
161
- const outputPath = path . join ( vscode . workspace . rootPath , output ) ;
160
+ if ( output || dc . output ) {
161
+ const outputPath = path . join ( vscode . workspace . rootPath , output || dc . output ) ;
162
162
args . push ( "--pref" , `build.path=${ outputPath } ` ) ;
163
163
}
164
164
165
165
arduinoChannel . show ( ) ;
166
166
// we need to return the result of verify
167
167
try {
168
- const result = await util . spawn ( this . _settings . commandPath , arduinoChannel . channel , args ) ;
168
+ await util . spawn ( this . _settings . commandPath , arduinoChannel . channel , args ) ;
169
169
arduinoChannel . end ( `Finished verify sketch - ${ dc . sketch } ${ os . EOL } ` ) ;
170
170
return true ;
171
171
} catch ( reason ) {
@@ -239,7 +239,7 @@ export class ArduinoApp {
239
239
if ( ! vscode . workspace . rootPath ) {
240
240
return ;
241
241
}
242
- const dc = DeviceContext . getIntance ( ) ;
242
+ const dc = DeviceContext . getInstance ( ) ;
243
243
const appPath = path . join ( vscode . workspace . rootPath , dc . sketch ) ;
244
244
if ( util . fileExistsSync ( appPath ) ) {
245
245
const hFiles = glob . sync ( `${ libraryPath } /*.h` , {
@@ -398,7 +398,7 @@ export class ArduinoApp {
398
398
} ) ;
399
399
if ( sketchFile ) {
400
400
// Generate arduino.json
401
- const dc = DeviceContext . getIntance ( ) ;
401
+ const dc = DeviceContext . getInstance ( ) ;
402
402
const arduinoJson = {
403
403
sketch : sketchFile ,
404
404
port : dc . port || "COM1" ,
@@ -458,14 +458,13 @@ export class ArduinoApp {
458
458
this . _exampleManager = value ;
459
459
}
460
460
461
- private getBoardBuildString ( deviceContext : IDeviceContext ) : string {
461
+ private getBoardBuildString ( ) : string {
462
462
const selectedBoard = this . boardManager . currentBoard ;
463
463
if ( ! selectedBoard ) {
464
464
Logger . notifyUserError ( "getBoardBuildString" , new Error ( constants . messages . NO_BOARD_SELECTED ) ) ;
465
465
return ;
466
466
}
467
- const boardString = selectedBoard . getBuildConfig ( ) ;
468
- return boardString ;
467
+ return selectedBoard . getBuildConfig ( ) ;
469
468
}
470
469
471
470
private async getMainSketch ( dc : DeviceContext ) {
0 commit comments