Skip to content

Commit

Permalink
fix: we should not create a cache folder if cache is false (#567)
Browse files Browse the repository at this point in the history
  • Loading branch information
bcoe committed May 5, 2017
1 parent 75713d8 commit 213206f
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
2 changes: 1 addition & 1 deletion index.js
Expand Up @@ -327,7 +327,7 @@ NYC.prototype.clearCache = function () {

NYC.prototype.createTempDirectory = function () {
mkdirp.sync(this.tempDirectory())
mkdirp.sync(this.cacheDirectory)
if (this.cache) mkdirp.sync(this.cacheDirectory)

if (this._showProcessTree) {
mkdirp.sync(this.processInfoDirectory())
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -10,7 +10,7 @@
"clean": "rimraf ./.nyc_output ./node_modules/.cache ./.self_coverage ./test/fixtures/.nyc_output ./test/fixtures/node_modules/.cache *covered.js ./lib/*covered.js",
"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-integration": "tap -t120 --no-cov -b ./test/build/*.js && mocha --timeout=15000 ./test/nyc-bin.js",
"test-mocha": "node ./bin/nyc --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"
Expand Down
24 changes: 21 additions & 3 deletions test/src/nyc-bin.js → test/nyc-bin.js
Expand Up @@ -2,10 +2,10 @@

var _ = require('lodash')
var path = require('path')
var bin = path.resolve(__dirname, '../../bin/nyc')
var fixturesCLI = path.resolve(__dirname, '../fixtures/cli')
var bin = path.resolve(__dirname, '../bin/nyc')
var fixturesCLI = path.resolve(__dirname, './fixtures/cli')
var fakebin = path.resolve(fixturesCLI, 'fakebin')
var fixturesHooks = path.resolve(__dirname, '../fixtures/hooks')
var fixturesHooks = path.resolve(__dirname, './fixtures/hooks')
var fs = require('fs')
var glob = require('glob')
var isWindows = require('is-windows')()
Expand Down Expand Up @@ -689,6 +689,24 @@ describe('the nyc cli', function () {
})
})

// see: https://github.com/istanbuljs/nyc/issues/563
it('does not create .cache folder if cache is "false"', function (done) {
var args = [bin, '--cache=false', process.execPath, './index.js']

var proc = spawn(process.execPath, args, {
cwd: process.cwd(),
env: env
})

rimraf.sync('./node_modules/.cache')

proc.on('close', function (code) {
code.should.equal(0)
fs.existsSync('./node_modules/.cache').should.equal(false)
done()
})
})

it('allows alternative high and low watermarks to be configured', function (done) {
var args = [
bin,
Expand Down
1 change: 1 addition & 0 deletions test/nyc.js
@@ -1,6 +1,7 @@
/* global describe, it */

const NYC = require('../')

require('chai').should()

describe('NYC', function () {
Expand Down

0 comments on commit 213206f

Please sign in to comment.