From 79e70acda51e5acec0fc1e77e6bf1a500361b30c Mon Sep 17 00:00:00 2001 From: Simone Corsi Date: Tue, 10 Jan 2023 11:51:28 +0100 Subject: [PATCH] fix: gte 100 exiting with 1 closes #122 --- bin/cmd.js | 2 +- tests/main.spec.js | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/bin/cmd.js b/bin/cmd.js index 38a5d51..d8636f0 100755 --- a/bin/cmd.js +++ b/bin/cmd.js @@ -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 = ""; } diff --git a/tests/main.spec.js b/tests/main.spec.js index 715186d..6462181 100644 --- a/tests/main.spec.js +++ b/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); @@ -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")); });