diff --git a/bin/nyc.js b/bin/nyc.js index e1688e0fe..01ab304c8 100755 --- a/bin/nyc.js +++ b/bin/nyc.js @@ -1,8 +1,5 @@ #!/usr/bin/env node -// the babel cache does not play nicely with nyc. -process.env.BABEL_DISABLE_CACHE = '1' - var configUtil = require('../lib/config-util') var foreground = require('foreground-child') var NYC @@ -50,9 +47,15 @@ if (argv._[0] === 'report') { NYC_CONFIG: JSON.stringify(config), NYC_CWD: process.cwd(), NYC_ROOT_ID: nyc.rootId, - BABEL_DISABLE_CACHE: 1, NYC_INSTRUMENTER: config.instrumenter } + + if (config['babel-cache'] === false) { + // babel's cache interferes with some configurations, so is + // disabled by default. opt in by setting babel-cache=true. + env.BABEL_DISABLE_CACHE = process.env.BABEL_DISABLE_CACHE = '1' + } + sw([wrapper], env) // Both running the test script invocation and the check-coverage run may diff --git a/lib/config-util.js b/lib/config-util.js index 98a201a68..2607702a8 100644 --- a/lib/config-util.js +++ b/lib/config-util.js @@ -142,6 +142,11 @@ Config.buildYargs = function (cwd) { type: 'boolean', describe: 'cache instrumentation results for improved performance' }) + .option('babel-cache', { + default: false, + type: 'boolean', + describe: 'cache babel transpilation results for improved performance' + }) .option('extension', { alias: 'e', default: [],