Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Don't upload if build fails #213

Merged
merged 2 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/commands/base-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export type BaseCommandOptions = {
extraOutput?: boolean;
successMessage?: string;
optionalArgs?: (string | undefined)[];
errorCallback?: (error: string) => void;
};
export class BaseCommand {
command: string;
Expand All @@ -47,6 +48,7 @@ export class BaseCommand {
exited: boolean = false;
extraOutput?: string[];
progressWindow: BackgroundProgress;
errorCallback?: (error: string) => void;

constructor(options: BaseCommandOptions) {
// the constructor is what is called whenever a new instance of the class is created
Expand Down Expand Up @@ -89,6 +91,7 @@ export class BaseCommand {
this.requiresProsProject = options.requiresProsProject;
this.extraOutput = options.extraOutput ? [] : undefined;
this.successMessage = options.successMessage;
this.errorCallback = options.errorCallback;

this.progressWindow = new BackgroundProgress(this.message, true, false);
// As far as implementing this onto each command, there are two ways you can do this.
Expand Down Expand Up @@ -180,6 +183,9 @@ export class BaseCommand {
child.stdout.on("data", (data) => {
this.parseOutput(data.toString().split(/\r?\n/), child).catch((e) => {
hasError = true;
if (this.errorCallback) {
this.errorCallback(e);
}
vscode.window.showErrorMessage(e, "View Output").then((response) => {
if (response) {
output.show();
Expand All @@ -190,6 +196,9 @@ export class BaseCommand {
child.stderr.on("data", (data) => {
this.parseOutput(data.toString().split(/\r?\n/), child).catch((e) => {
hasError = true;
if (this.errorCallback) {
this.errorCallback(e);
}
vscode.window.showErrorMessage(e, "View Output").then((response) => {
if (response) {
output.show();
Expand Down
8 changes: 7 additions & 1 deletion src/commands/buildUpload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,24 @@ import { window } from "vscode";
import { upload } from "./upload";

export const buildUpload = async () => {
var buildFailed = false;
const buildCommandOptions: BaseCommandOptions = {
command: "pros",
args: ["make"],
message: "Building Project",
requiresProsProject: true,
successMessage: "hidden",
errorCallback: () => {
buildFailed = true;
},
};
const buildCommand: BaseCommand = new BaseCommand(buildCommandOptions);
try {
await buildCommand.runCommand();
} catch (err: any) {
await window.showErrorMessage(err.message);
}
await upload();
if (!buildFailed) {
await upload();
}
};
Loading