Skip to content
This repository was archived by the owner on Oct 1, 2024. It is now read-only.

Commit 2039739

Browse files
hlovdaladiazulay
authored andcommitted
Make build return boolean
1 parent fef2db0 commit 2039739

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

src/arduino/arduino.ts

+13-9
Original file line numberDiff line numberDiff line change
@@ -115,15 +115,15 @@ export class ArduinoApp {
115115
let restoreSerialMonitor: boolean = false;
116116
const boardDescriptor = this.getBoardBuildString();
117117
if (!boardDescriptor) {
118-
return;
118+
return false;
119119
}
120120
if (!this.useArduinoCli()) {
121121
args.push("--board", boardDescriptor);
122122
}
123123

124124
if (!ArduinoWorkspace.rootPath) {
125125
vscode.window.showWarningMessage("Cannot find the sketch file.");
126-
return;
126+
return false;
127127
}
128128

129129
if (!dc.sketch || !util.fileExistsSync(path.join(ArduinoWorkspace.rootPath, dc.sketch))) {
@@ -142,12 +142,12 @@ export class ArduinoApp {
142142
if (buildMode === BuildMode.Upload) {
143143
if ((!dc.configuration || !/upload_method=[^=,]*st[^,]*link/i.test(dc.configuration)) && !dc.port) {
144144
await selectSerial();
145-
return;
145+
return false;
146146
}
147147

148148
if (!compile && !this.useArduinoCli()) {
149149
arduinoChannel.error("This command is only available when using the Arduino CLI");
150-
return;
150+
return false;
151151
}
152152

153153
if (!this.useArduinoCli()) {
@@ -168,16 +168,16 @@ export class ArduinoApp {
168168
} else if (buildMode === BuildMode.UploadProgrammer) {
169169
const programmer = this.getProgrammerString();
170170
if (!programmer) {
171-
return;
171+
return false;
172172
}
173173
if (!dc.port) {
174174
await selectSerial();
175-
return;
175+
return false;
176176
}
177177

178178
if (!compile && !this.useArduinoCli()) {
179179
arduinoChannel.error("This command is only available when using the Arduino CLI");
180-
return;
180+
return false;
181181
}
182182

183183
if (!this.useArduinoCli()) {
@@ -212,15 +212,15 @@ export class ArduinoApp {
212212
arduinoChannel.start(`${buildMode} sketch '${dc.sketch}'`);
213213

214214
if (!await this.runPreBuildCommand(dc)) {
215-
return;
215+
return false;
216216
}
217217

218218
if (dc.output && compile) {
219219
const outputPath = path.resolve(ArduinoWorkspace.rootPath, dc.output);
220220
const dirPath = path.dirname(outputPath);
221221
if (!util.directoryExistsSync(dirPath)) {
222222
logger.notifyUserError("InvalidOutPutPath", new Error(constants.messages.INVALID_OUTPUT_PATH + outputPath));
223-
return;
223+
return false;
224224
}
225225

226226
if (this.useArduinoCli()) {
@@ -243,6 +243,8 @@ export class ArduinoApp {
243243
UsbDetector.getInstance().pauseListening();
244244
}
245245

246+
let success = false;
247+
246248
// Push sketch as last argument
247249
args.push(path.join(ArduinoWorkspace.rootPath, dc.sketch));
248250

@@ -270,6 +272,7 @@ export class ArduinoApp {
270272
).then(async () => {
271273
await cleanup();
272274
arduinoChannel.end(`${buildMode} sketch '${dc.sketch}'${os.EOL}`);
275+
success = true;
273276
}, async (reason) => {
274277
await cleanup();
275278
const msg = reason.code ?
@@ -279,6 +282,7 @@ export class ArduinoApp {
279282
JSON.stringify(reason);
280283
arduinoChannel.error(`${buildMode} sketch '${dc.sketch}': ${msg}${os.EOL}`);
281284
});
285+
return success;
282286
}
283287

284288
public async verify(buildMode: BuildMode, buildDir: string = "") {

0 commit comments

Comments
 (0)