From 2dd1139e551487ee46b7689e0f65b467cf672f86 Mon Sep 17 00:00:00 2001 From: Jan W Date: Mon, 16 Sep 2024 08:41:35 +0200 Subject: [PATCH] feat: enable coverage through EXODUS_TEST_COVERAGE --- bin/index.js | 3 ++- src/env.js | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 src/env.js diff --git a/bin/index.js b/bin/index.js index d03f1b1..f0254b1 100755 --- a/bin/index.js +++ b/bin/index.js @@ -14,6 +14,7 @@ import assert from 'node:assert/strict' import { Queue } from '@chalker/queue' import glob from 'fast-glob' import { haveModuleMocks, haveSnapshots, haveForceExit } from '../src/version.js' +import { isTruthy } from '../src/env.js' const bindir = dirname(fileURLToPath(import.meta.url)) const DEFAULT_PATTERNS = [`**/?(*.)+(spec|test).?([cm])[jt]s?(x)`] // do not trust magic dirs by default @@ -42,7 +43,7 @@ function parseOptions() { flow: false, esbuild: false, babel: false, - coverage: false, + coverage: isTruthy(process.env.EXODUS_TEST_COVERAGE), coverageEngine: 'c8', // c8 or node watch: false, only: false, diff --git a/src/env.js b/src/env.js new file mode 100644 index 0000000..1804248 --- /dev/null +++ b/src/env.js @@ -0,0 +1,5 @@ +const truthy = new Set(['true', '1', 'yes', 'y', 'on']) + +export function isTruthy(envVar) { + return truthy.has(envVar) +}