Skip to content

Commit 98ebdff

Browse files
authored
feat: allow babel cache to be enabled (#517)
1 parent 50adde4 commit 98ebdff

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

bin/nyc.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
#!/usr/bin/env node
22

3-
// the babel cache does not play nicely with nyc.
4-
process.env.BABEL_DISABLE_CACHE = '1'
5-
63
var configUtil = require('../lib/config-util')
74
var foreground = require('foreground-child')
85
var NYC
@@ -50,9 +47,15 @@ if (argv._[0] === 'report') {
5047
NYC_CONFIG: JSON.stringify(config),
5148
NYC_CWD: process.cwd(),
5249
NYC_ROOT_ID: nyc.rootId,
53-
BABEL_DISABLE_CACHE: 1,
5450
NYC_INSTRUMENTER: config.instrumenter
5551
}
52+
53+
if (config['babel-cache'] === false) {
54+
// babel's cache interferes with some configurations, so is
55+
// disabled by default. opt in by setting babel-cache=true.
56+
env.BABEL_DISABLE_CACHE = process.env.BABEL_DISABLE_CACHE = '1'
57+
}
58+
5659
sw([wrapper], env)
5760

5861
// Both running the test script invocation and the check-coverage run may

lib/config-util.js

+5
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,11 @@ Config.buildYargs = function (cwd) {
142142
type: 'boolean',
143143
describe: 'cache instrumentation results for improved performance'
144144
})
145+
.option('babel-cache', {
146+
default: false,
147+
type: 'boolean',
148+
describe: 'cache babel transpilation results for improved performance'
149+
})
145150
.option('extension', {
146151
alias: 'e',
147152
default: [],

0 commit comments

Comments
 (0)