Skip to content

Commit

Permalink
feat: allow an alternate cache folder to be provided (#443)
Browse files Browse the repository at this point in the history
  • Loading branch information
bcoe committed Nov 13, 2016
1 parent 2828538 commit b6713a3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function NYC (config) {

this.reporter = arrify(config.reporter || 'text')

this.cacheDirectory = findCacheDir({name: 'nyc', cwd: this.cwd})
this.cacheDirectory = config.cacheDir || findCacheDir({name: 'nyc', cwd: this.cwd})

this.enableCache = Boolean(this.cacheDirectory && (config.enableCache === true || process.env.NYC_CACHE === 'enable'))

Expand Down
19 changes: 19 additions & 0 deletions test/src/nyc-bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -670,4 +670,23 @@ describe('the nyc cli', function () {
})
})
})

it('allows an alternative cache folder to be specified', function (done) {
var args = [bin, '--cache-dir=./foo-cache', '--cache=true', process.execPath, './half-covered.js']

var proc = spawn(process.execPath, args, {
cwd: fixturesCLI,
env: env
})
proc.on('close', function (code) {
code.should.equal(0)
// we should have created ./foo-cache rather
// than the default ./node_modules/.cache.
fs.readdirSync(path.resolve(
fixturesCLI, './foo-cache'
)).length.should.equal(1)
rimraf.sync(path.resolve(fixturesCLI, 'foo-cache'))
done()
})
})
})

0 comments on commit b6713a3

Please sign in to comment.