Skip to content

Commit 3879639

Browse files
hlovdaladiazulay
authored andcommitted
Move args variable till top of upload, uploadUsingProgrammer and verify
1 parent dd308ac commit 3879639

File tree

1 file changed

+27
-5
lines changed

1 file changed

+27
-5
lines changed

src/arduino/arduino.ts

+27-5
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,14 @@ export class ArduinoApp {
101101
*/
102102
public async upload(compile: boolean = true, useProgrammer: boolean = false) {
103103
const dc = DeviceContext.getInstance();
104+
const args: string[] = [];
104105
const boardDescriptor = this.getBoardBuildString();
105106
if (!boardDescriptor) {
106107
return;
107108
}
109+
if (!this.useArduinoCli()) {
110+
args.push("--board", boardDescriptor);
111+
}
108112

109113
const selectProgrammer = useProgrammer ? this.getProgrammerString() : null;
110114
if (useProgrammer && !selectProgrammer) {
@@ -149,10 +153,17 @@ export class ArduinoApp {
149153
}
150154

151155
const appPath = path.join(ArduinoWorkspace.rootPath, dc.sketch);
152-
// TODO: add the --clean argument to the cli args when v 0.14 is released (this will clean up the build folder after uploading)
153-
const args = (!compile && this.useArduinoCli()) ? ["upload", "-b", boardDescriptor] :
154-
this.useArduinoCli() ? ["compile", "--upload", "-b", boardDescriptor] :
155-
["--upload", "--board", boardDescriptor];
156+
if (!this.useArduinoCli()) {
157+
args.push("--upload");
158+
} else {
159+
// TODO: add the --clean argument to the cli args when v 0.14 is released (this will clean up the build folder after uploading)
160+
if (compile) {
161+
args.push("compile", "--upload");
162+
} else {
163+
args.push("upload");
164+
}
165+
args.push("-b", boardDescriptor);
166+
}
156167

157168
if (useProgrammer) {
158169
if (this.useArduinoCli()) {
@@ -206,10 +217,14 @@ export class ArduinoApp {
206217

207218
public async verify(output: string = "") {
208219
const dc = DeviceContext.getInstance();
220+
const args: string[] = [];
209221
const boardDescriptor = this.getBoardBuildString();
210222
if (!boardDescriptor) {
211223
return false;
212224
}
225+
if (!this.useArduinoCli()) {
226+
args.push("--board", boardDescriptor);
227+
}
213228

214229
if (!ArduinoWorkspace.rootPath) {
215230
vscode.window.showWarningMessage("Cannot find the sketch file.");
@@ -229,7 +244,14 @@ export class ArduinoApp {
229244
}
230245

231246
const appPath = path.join(ArduinoWorkspace.rootPath, dc.sketch);
232-
const args = this.useArduinoCli() ? ["compile", "-b", boardDescriptor, appPath] : ["--verify", "--board", boardDescriptor, appPath];
247+
248+
if (!this.useArduinoCli()) {
249+
args.push("--verify");
250+
} else {
251+
args.push("compile", "-b", boardDescriptor);
252+
}
253+
254+
args.push(appPath);
233255
if (VscodeSettings.getInstance().logLevel === "verbose") {
234256
args.push("--verbose");
235257
}

0 commit comments

Comments
 (0)