From 35cd49adab7be33e77b882c02fb07ae7e0c87fc5 Mon Sep 17 00:00:00 2001 From: Kenton Jacobsen Date: Sat, 19 Jan 2019 16:57:46 -0500 Subject: [PATCH] feat: document the fact that cacheDir is configurable (#968) --- README.md | 4 +--- lib/config-util.js | 4 ++++ test/nyc-bin.js | 6 ++++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 66eea259b..8906b4a90 100644 --- a/README.md +++ b/README.md @@ -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` diff --git a/lib/config-util.js b/lib/config-util.js index 19bbeec54..ae62d2ab6 100644 --- a/lib/config-util.js +++ b/lib/config-util.js @@ -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', diff --git a/test/nyc-bin.js b/test/nyc-bin.js index 8588648c6..a22ea4c09 100644 --- a/test/nyc-bin.js +++ b/test/nyc-bin.js @@ -278,7 +278,8 @@ 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' @@ -286,7 +287,8 @@ describe('the nyc cli', function () { var expected = { instrumenter: './lib/instrumenters/istanbul', silent: true, - cache: true, + cacheDir: '/tmp', + cache: false, sourceMap: true }