From b909575e60c1b8107d950e71fe1667f91d42b9c5 Mon Sep 17 00:00:00 2001 From: Corey Farrell Date: Fri, 5 Apr 2019 14:16:03 -0400 Subject: [PATCH] fix: Use a single instance of nyc for all actions of main command. (#1059) This shares the same instance of nyc for execution, checking coverage and reporting. --- bin/nyc.js | 36 ++++++++++++------------------------ 1 file changed, 12 insertions(+), 24 deletions(-) diff --git a/bin/nyc.js b/bin/nyc.js index c285c5abe..2a2ea38e2 100755 --- a/bin/nyc.js +++ b/bin/nyc.js @@ -66,34 +66,22 @@ if ([ var mainChildExitCode = process.exitCode if (argv.checkCoverage) { - checkCoverage(argv) + nyc.checkCoverage({ + lines: argv.lines, + functions: argv.functions, + branches: argv.branches, + statements: argv.statements + }, argv['per-file']) process.exitCode = process.exitCode || mainChildExitCode - if (!argv.silent) report(argv) - return done() - } else { - if (!argv.silent) report(argv) - return done() } + + if (!argv.silent) { + nyc.report() + } + + return done() }) } else { // I don't have a clue what you're doing. yargs.showHelp() } - -function report (argv) { - process.env.NYC_CWD = process.cwd() - - var nyc = new NYC(argv) - nyc.report() -} - -function checkCoverage (argv, cb) { - process.env.NYC_CWD = process.cwd() - - ;(new NYC(argv)).checkCoverage({ - lines: argv.lines, - functions: argv.functions, - branches: argv.branches, - statements: argv.statements - }, argv['per-file']) -}