Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resolves #765 resolve custom cache directory to an absolute path #766

Merged
merged 1 commit into from
Feb 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function NYC (config) {
this.cwd = config.cwd || process.cwd()
this.reporter = arrify(config.reporter || 'text')

this.cacheDirectory = config.cacheDir || findCacheDir({name: 'nyc', cwd: this.cwd})
this.cacheDirectory = (config.cacheDir && path.resolve(config.cacheDir)) || findCacheDir({name: 'nyc', cwd: this.cwd})
this.cache = Boolean(this.cacheDirectory && config.cache)

this.exclude = testExclude({
Expand Down
18 changes: 18 additions & 0 deletions test/nyc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* global describe, it */

const NYC = require('../')
const path = require('path')

require('chai').should()

Expand All @@ -27,4 +28,21 @@ describe('NYC', function () {
nyc._disableCachingTransform().should.equal(false)
})
})

describe('cacheDirectory', function () {
it('should resolve default cache folder to absolute path', function () {
const nyc = new NYC({
cache: true
})
path.isAbsolute(nyc.cacheDirectory).should.equal(true)
})

it('should resolve custom cache folder to absolute path', function () {
const nyc = new NYC({
cacheDir: '.nyc_cache',
cache: true
})
path.isAbsolute(nyc.cacheDirectory).should.equal(true)
})
})
})