Skip to content

Commit

Permalink
fix: Use a single instance of nyc for all actions of main command.
Browse files Browse the repository at this point in the history
This shares the same instance of nyc for execution, checking coverage
and reporting.
  • Loading branch information
coreyfarrell committed Apr 5, 2019
1 parent 997ed29 commit c86356d
Showing 1 changed file with 12 additions and 24 deletions.
36 changes: 12 additions & 24 deletions bin/nyc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'])
}

0 comments on commit c86356d

Please sign in to comment.