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

Commit

Permalink
Make build return boolean
Browse files Browse the repository at this point in the history
  • Loading branch information
hlovdal authored and adiazulay committed Jan 19, 2021
1 parent fef2db0 commit 2039739
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/arduino/arduino.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,15 @@ export class ArduinoApp {
let restoreSerialMonitor: boolean = false;
const boardDescriptor = this.getBoardBuildString();
if (!boardDescriptor) {
return;
return false;
}
if (!this.useArduinoCli()) {
args.push("--board", boardDescriptor);
}

if (!ArduinoWorkspace.rootPath) {
vscode.window.showWarningMessage("Cannot find the sketch file.");
return;
return false;
}

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

if (!compile && !this.useArduinoCli()) {
arduinoChannel.error("This command is only available when using the Arduino CLI");
return;
return false;
}

if (!this.useArduinoCli()) {
Expand All @@ -168,16 +168,16 @@ export class ArduinoApp {
} else if (buildMode === BuildMode.UploadProgrammer) {
const programmer = this.getProgrammerString();
if (!programmer) {
return;
return false;
}
if (!dc.port) {
await selectSerial();
return;
return false;
}

if (!compile && !this.useArduinoCli()) {
arduinoChannel.error("This command is only available when using the Arduino CLI");
return;
return false;
}

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

if (!await this.runPreBuildCommand(dc)) {
return;
return false;
}

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

if (this.useArduinoCli()) {
Expand All @@ -243,6 +243,8 @@ export class ArduinoApp {
UsbDetector.getInstance().pauseListening();
}

let success = false;

// Push sketch as last argument
args.push(path.join(ArduinoWorkspace.rootPath, dc.sketch));

Expand Down Expand Up @@ -270,6 +272,7 @@ export class ArduinoApp {
).then(async () => {
await cleanup();
arduinoChannel.end(`${buildMode} sketch '${dc.sketch}'${os.EOL}`);
success = true;
}, async (reason) => {
await cleanup();
const msg = reason.code ?
Expand All @@ -279,6 +282,7 @@ export class ArduinoApp {
JSON.stringify(reason);
arduinoChannel.error(`${buildMode} sketch '${dc.sketch}': ${msg}${os.EOL}`);
});
return success;
}

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

0 comments on commit 2039739

Please sign in to comment.