Add cache.clear() to clear the data reference when cache option is false.
This commit is contained in:
parent
47a93d6e2b
commit
330f9006a7
@ -62,3 +62,11 @@ export function load() {
|
||||
export function get(): Object {
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the cache object.
|
||||
*/
|
||||
|
||||
export function clear() {
|
||||
data = {};
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user