Skip to content

Commit 213206f

Browse files
authored
fix: we should not create a cache folder if cache is false (#567)
1 parent 75713d8 commit 213206f

File tree

4 files changed

+24
-5
lines changed

4 files changed

+24
-5
lines changed

index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ NYC.prototype.clearCache = function () {
327327

328328
NYC.prototype.createTempDirectory = function () {
329329
mkdirp.sync(this.tempDirectory())
330-
mkdirp.sync(this.cacheDirectory)
330+
if (this.cache) mkdirp.sync(this.cacheDirectory)
331331

332332
if (this._showProcessTree) {
333333
mkdirp.sync(this.processInfoDirectory())

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"clean": "rimraf ./.nyc_output ./node_modules/.cache ./.self_coverage ./test/fixtures/.nyc_output ./test/fixtures/node_modules/.cache *covered.js ./lib/*covered.js",
1111
"build": "node ./build-tests",
1212
"instrument": "node ./build-self-coverage.js",
13-
"test-integration": "tap -t120 --no-cov -b ./test/build/*.js && mocha --timeout=15000 ./test/src/nyc-bin.js",
13+
"test-integration": "tap -t120 --no-cov -b ./test/build/*.js && mocha --timeout=15000 ./test/nyc-bin.js",
1414
"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"

test/src/nyc-bin.js test/nyc-bin.js

+21-3
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
var _ = require('lodash')
44
var path = require('path')
5-
var bin = path.resolve(__dirname, '../../bin/nyc')
6-
var fixturesCLI = path.resolve(__dirname, '../fixtures/cli')
5+
var bin = path.resolve(__dirname, '../bin/nyc')
6+
var fixturesCLI = path.resolve(__dirname, './fixtures/cli')
77
var fakebin = path.resolve(fixturesCLI, 'fakebin')
8-
var fixturesHooks = path.resolve(__dirname, '../fixtures/hooks')
8+
var fixturesHooks = path.resolve(__dirname, './fixtures/hooks')
99
var fs = require('fs')
1010
var glob = require('glob')
1111
var isWindows = require('is-windows')()
@@ -689,6 +689,24 @@ describe('the nyc cli', function () {
689689
})
690690
})
691691

692+
// see: https://github.com/istanbuljs/nyc/issues/563
693+
it('does not create .cache folder if cache is "false"', function (done) {
694+
var args = [bin, '--cache=false', process.execPath, './index.js']
695+
696+
var proc = spawn(process.execPath, args, {
697+
cwd: process.cwd(),
698+
env: env
699+
})
700+
701+
rimraf.sync('./node_modules/.cache')
702+
703+
proc.on('close', function (code) {
704+
code.should.equal(0)
705+
fs.existsSync('./node_modules/.cache').should.equal(false)
706+
done()
707+
})
708+
})
709+
692710
it('allows alternative high and low watermarks to be configured', function (done) {
693711
var args = [
694712
bin,

test/nyc.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* global describe, it */
22

33
const NYC = require('../')
4+
45
require('chai').should()
56

67
describe('NYC', function () {

0 commit comments

Comments
 (0)