Skip to content

Commit

Permalink
fix(code): system.exit(1) on errors
Browse files Browse the repository at this point in the history
  • Loading branch information
crherman7 committed Mar 25, 2024
1 parent 91eb476 commit 6839828
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion packages/cli/src/cmds/prebuild.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Option, program } from "commander";
import type { PrebuildOptions } from "@brandingbrand/code-cli-kit";

import { config, emitter, logger } from "@/lib";
import * as actions from "@/actions";
import { Reporter } from "@/components";
import { config, emitter, logger, actions as actionsRes } from "@/lib";

/**
* Defines a command for the "prebuild" operation using the "commander" library.
Expand Down Expand Up @@ -89,4 +89,12 @@ program
* Resume logging with console.log and process.stdout
*/
logger.resume();

/**
* Exit process with error if errors exist; this is important for
* registering errors with continuous integration.
*/
if (actionsRes.some((it) => it.error)) {
process.exit(1);
}
});
2 changes: 1 addition & 1 deletion packages/cli/src/lib/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export function withAction<TResult, TArgs extends unknown[]>(
name,
time: `${((performance.now() - start) / 1000).toFixed(5)} s`,
success: false,
error: isWarningType ? false : error.message,
error: isWarningType ? false : error.message ? error.message : true,
warning: isWarningType ? error.message : false,
});
}
Expand Down

0 comments on commit 6839828

Please sign in to comment.