Skip to content

Commit

Permalink
Merge pull request #5 from istanbuljs/master
Browse files Browse the repository at this point in the history
Get latest
  • Loading branch information
AndrewFinlay authored Jan 25, 2019
2 parents 94715f0 + 35cd49a commit 6760d1d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,7 @@ modules should be required in the subprocess collecting coverage:

## Caching

You can run `nyc` with the optional `--cache` flag, to prevent it from
instrumenting the same files multiple times. This can significantly
improve runtime performance.
`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.

## Configuring `nyc`

Expand Down
3 changes: 3 additions & 0 deletions bin/nyc.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ if ([
if (argv.all) nyc.addAllFiles()

var env = {
// Support running nyc as a user without HOME (e.g. linux 'nobody'),
// https://github.com/istanbuljs/nyc/issues/951
SPAWN_WRAP_SHIM_ROOT: process.env.SPAWN_WRAP_SHIM_ROOT || process.env.XDG_CACHE_HOME || require('os').homedir(),
NYC_CONFIG: JSON.stringify(argv),
NYC_CWD: process.cwd(),
NYC_ROOT_ID: nyc.rootId,
Expand Down
4 changes: 4 additions & 0 deletions lib/config-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ Config.buildYargs = function (cwd) {
describe: 'cache instrumentation results for improved performance',
global: false
})
.option('cache-dir', {
describe: 'explicitly set location for instrumentation cache',
global: false
})
.option('babel-cache', {
default: false,
type: 'boolean',
Expand Down
6 changes: 4 additions & 2 deletions test/nyc-bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,15 +278,17 @@ describe('the nyc cli', function () {
'--include=env.js',
'--exclude=batman.js',
'--extension=.js',
'--cache=true',
'--cache=false',
'--cache-dir=/tmp',
'--source-map=true',
process.execPath,
'./env.js'
]
var expected = {
instrumenter: './lib/instrumenters/istanbul',
silent: true,
cache: true,
cacheDir: '/tmp',
cache: false,
sourceMap: true
}

Expand Down

0 comments on commit 6760d1d

Please sign in to comment.