Skip to content

Commit 1887d1c

Browse files
authored
feat: add support for --no-clean, to disable deleting raw coverage output (#558)
1 parent ff73b18 commit 1887d1c

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

bin/nyc.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ if (argv._[0] === 'report') {
3838
else config.instrumenter = './lib/instrumenters/istanbul'
3939

4040
var nyc = (new NYC(config))
41-
nyc.reset()
42-
41+
if (config.clean) nyc.reset()
4342
if (config.all) nyc.addAllFiles()
4443

4544
var env = {

lib/config-util.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ Config.buildYargs = function (cwd) {
6464
default: 'coverage'
6565
})
6666
.option('temp-directory', {
67-
describe: 'directory from which coverage JSON files are read',
67+
describe: 'directory to read raw coverage information from',
6868
default: './.nyc_output'
6969
})
7070
.option('show-process-tree', {
@@ -219,6 +219,17 @@ Config.buildYargs = function (cwd) {
219219
type: 'boolean',
220220
global: false
221221
})
222+
.option('clean', {
223+
describe: 'should the .nyc_output folder be cleaned before executing tests',
224+
default: true,
225+
type: 'boolean',
226+
global: false
227+
})
228+
.option('temp-directory', {
229+
describe: 'directory to output raw coverage information to',
230+
default: './.nyc_output',
231+
global: false
232+
})
222233
.pkgConf('nyc', cwd || process.cwd())
223234
.example('$0 npm test', 'instrument your tests with coverage')
224235
.example('$0 --require babel-core/register npm test', 'instrument your tests with coverage and babel')

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"build": "node ./build-tests",
1212
"instrument": "node ./build-self-coverage.js",
1313
"test-integration": "tap -t120 --no-cov -b ./test/build/*.js && mocha --timeout=15000 ./test/src/nyc-bin.js",
14-
"test-mocha": "node ./bin/nyc --silent --temp-directory=./.self_coverage mocha ./test/nyc.js ./test/process-args.js",
14+
"test-mocha": "node ./bin/nyc --no-clean --silent --temp-directory=./.self_coverage mocha ./test/nyc.js ./test/process-args.js",
1515
"report": "node ./bin/nyc --temp-directory ./.self_coverage/ -r text -r lcov report",
1616
"release": "standard-version"
1717
},

0 commit comments

Comments
 (0)