Add cache.clear() to clear the data reference when cache option is false.

This commit is contained in:
John-David Dalton
2017-11-09 15:49:26 -08:00
committed by Logan Smyth
parent 47a93d6e2b
commit 330f9006a7
2 changed files with 16 additions and 3 deletions

View File

@@ -30,8 +30,7 @@ function installSourceMapSupport() {
});
}
registerCache.load();
let cache = registerCache.get();
let cache;
function mtime(filename) {
return +fs.statSync(filename).mtime;
@@ -103,7 +102,13 @@ export default function register(opts?: Object = {}) {
opts = Object.assign({}, opts);
if (opts.extensions) hookExtensions(opts.extensions);
if (opts.cache === false) cache = null;
if (opts.cache === false && cache) {
registerCache.clear();
cache = null;
} else if (opts.cache !== false && !cache) {
registerCache.load();
cache = registerCache.get();
}
delete opts.extensions;
delete opts.cache;