From 50e315fbcf027cc655c7e30e8d20fa6381fdbb42 Mon Sep 17 00:00:00 2001 From: Moshe Atlow Date: Tue, 21 May 2024 12:12:39 +0300 Subject: [PATCH] feat: auto detect .nycrc file (#17) --- borp.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/borp.js b/borp.js index ea15911..bbd6bfa 100755 --- a/borp.js +++ b/borp.js @@ -2,6 +2,7 @@ import { parseArgs } from 'node:util' import Reporters from 'node:test/reporters' +import { findUp } from 'find-up' import { mkdtemp, rm, readFile } from 'node:fs/promises' import { createWriteStream } from 'node:fs' import { finished } from 'node:stream/promises' @@ -141,10 +142,12 @@ try { const localPrefix = relative(process.cwd(), config.prefix) exclude = exclude.map((file) => posix.join(localPrefix, file)) } + const nycrc = await findUp(['.c8rc', '.c8rc.json', '.nycrc', '.nycrc.json'], { cwd: config.cwd }) const report = Report({ reporter: ['text'], tempDirectory: covDir, - exclude + exclude, + ...nycrc && JSON.parse(await readFile(nycrc, 'utf8')) }) if (args.values['check-coverage']) {