Skip to content

Commit

Permalink
fix: gte 100 exiting with 1
Browse files Browse the repository at this point in the history
closes #122
  • Loading branch information
simonecorsi committed Jan 10, 2023
1 parent c61dac9 commit 79e70ac
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion bin/cmd.js
Expand Up @@ -19,7 +19,7 @@ let min = 0;
if (gte) {
const [, value] = gte.split("=");
min = !isNaN(parseInt(value)) ? parseFloat(value) : 0;
process.exitCode = result > min ? 0 : 1;
process.exitCode = result >= min ? 0 : 1;
returnVal = "";
}

Expand Down
11 changes: 9 additions & 2 deletions tests/main.spec.js
@@ -1,7 +1,8 @@
import total from "../src/index.js";
// eslint-disable-next-line node/no-missing-import
import test from "ava";
import { exec as ex } from "child_process";
import total from "../src/index.js";
import util from "util";
import { exec as ex } from "node:child_process";

const exec = util.promisify(ex);

Expand Down Expand Up @@ -33,6 +34,12 @@ test("Should exit(0) if greater than equal then 90", async (t) => {
t.is(stderr, "");
});

test("Should exit(1) if checking for --gte=100", async (t) => {
await t.throwsAsync(
exec("node ./bin/cmd.js ./tests/fixtures/lcov.info --gte=100")
);
});

test("Should error on file missing", async (t) => {
await t.throwsAsync(() => exec("node ./bin/cmd.js"));
});
Expand Down

0 comments on commit 79e70ac

Please sign in to comment.