diff --git a/bin/nyc.js b/bin/nyc.js index 8f62054a3..5428c4e61 100755 --- a/bin/nyc.js +++ b/bin/nyc.js @@ -38,8 +38,7 @@ if (argv._[0] === 'report') { else config.instrumenter = './lib/instrumenters/istanbul' var nyc = (new NYC(config)) - nyc.reset() - + if (config.clean) nyc.reset() if (config.all) nyc.addAllFiles() var env = { diff --git a/lib/config-util.js b/lib/config-util.js index 5bdc177cf..dd7bb085a 100644 --- a/lib/config-util.js +++ b/lib/config-util.js @@ -219,6 +219,17 @@ Config.buildYargs = function (cwd) { type: 'boolean', global: false }) + .option('clean', { + describe: 'should the .nyc_output folder be deleted before executing tests', + default: true, + type: 'boolean', + global: false + }) + .option('temp-directory', { + describe: 'directory to output raw coverage data in', + default: './.nyc_output', + global: false + }) .pkgConf('nyc', cwd || process.cwd()) .example('$0 npm test', 'instrument your tests with coverage') .example('$0 --require babel-core/register npm test', 'instrument your tests with coverage and babel') diff --git a/package.json b/package.json index 533dc1b1a..63563b0dd 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "build": "node ./build-tests", "instrument": "node ./build-self-coverage.js", "test-integration": "tap -t120 --no-cov -b ./test/build/*.js && mocha --timeout=15000 ./test/src/nyc-bin.js", - "test-mocha": "./bin/nyc.js --silent --temp-directory=./.self_coverage mocha ./test/nyc.js ./test/process-args.js", + "test-mocha": "./bin/nyc.js --no-clean --silent --temp-directory=./.self_coverage mocha ./test/nyc.js ./test/process-args.js", "report": "node ./bin/nyc --temp-directory ./.self_coverage/ -r text -r lcov report", "release": "standard-version" },