Skip to content

Commit

Permalink
Merge pull request #303 from Moonsong-Labs/force-exit
Browse files Browse the repository at this point in the history
force exit
  • Loading branch information
timbrinded authored Nov 8, 2023
2 parents 5a7c5f0 + 9681945 commit 30481ec
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/silver-peaches-lie.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@moonwall/cli": patch
---

Force exit on failure
10 changes: 7 additions & 3 deletions packages/cli/src/cmds/entrypoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,13 @@ yargs(hideBin(process.argv))
async (args) => {
if (args.envName) {
process.env.MOON_RUN_SCRIPTS = "true";
(await testCmd(args.envName.toString(), { testNamePattern: args.GrepTest }))
? process.exit(0)
: process.exit(1);
if (await testCmd(args.envName.toString(), { testNamePattern: args.GrepTest })) {
console.log("✅ All tests passed");
process.exit(0);
} else {
console.log("❌ Some tests failed");
process.kill(process.pid, "SIGTERM");
}
} else {
console.log("❌ No environment specified");
console.log(`👉 Run 'pnpm moonwall --help' for more information`);
Expand Down
1 change: 0 additions & 1 deletion packages/cli/src/cmds/runTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ export async function testCmd(envName: string, additionalArgs?: object): Promise
const failed = vitest!.state.getFiles().filter((file) => file.result!.state === "fail");

if (failed.length > 0) {
process.stderr.write("Tests failed\n");
return false;
} else {
return true;
Expand Down

0 comments on commit 30481ec

Please sign in to comment.