Skip to content

Commit 35cd49a

Browse files
brokentonebcoe
authored andcommitted
feat: document the fact that cacheDir is configurable (#968)
1 parent ff834aa commit 35cd49a

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

README.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,7 @@ modules should be required in the subprocess collecting coverage:
251251

252252
## Caching
253253

254-
You can run `nyc` with the optional `--cache` flag, to prevent it from
255-
instrumenting the same files multiple times. This can significantly
256-
improve runtime performance.
254+
`nyc`'s default behavior is to cache instrumented files to disk to prevent instrumenting source files multiple times, and speed `nyc` execution times. You can disable this behavior by running `nyc` with the `--cache false` flag. You can also change the default cache directory from `./node_modules/.cache/nyc` by setting the `--cache-dir` flag.
257255

258256
## Configuring `nyc`
259257

lib/config-util.js

+4
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ Config.buildYargs = function (cwd) {
109109
describe: 'cache instrumentation results for improved performance',
110110
global: false
111111
})
112+
.option('cache-dir', {
113+
describe: 'explicitly set location for instrumentation cache',
114+
global: false
115+
})
112116
.option('babel-cache', {
113117
default: false,
114118
type: 'boolean',

test/nyc-bin.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -278,15 +278,17 @@ describe('the nyc cli', function () {
278278
'--include=env.js',
279279
'--exclude=batman.js',
280280
'--extension=.js',
281-
'--cache=true',
281+
'--cache=false',
282+
'--cache-dir=/tmp',
282283
'--source-map=true',
283284
process.execPath,
284285
'./env.js'
285286
]
286287
var expected = {
287288
instrumenter: './lib/instrumenters/istanbul',
288289
silent: true,
289-
cache: true,
290+
cacheDir: '/tmp',
291+
cache: false,
290292
sourceMap: true
291293
}
292294

0 commit comments

Comments
 (0)