Commit ec62b3b2 authored by Suhaimi Amir's avatar Suhaimi Amir

fix onupdate bug

parent eb558d99
Pipeline #1121 passed with stage
in 34 seconds
......@@ -35,7 +35,14 @@ exports.get = async (name) => {
};
// check if config has changed
exports.onChange = (name, filesToUncache = []) => {
exports.onChange = (name, files = []) => {
let pleaseUncache = files;
if (!Array.isArray(pleaseUncache)) {
pleaseUncache = [];
pleaseUncache.push(files);
}
if (configSubscriber === null) { // only run if we're listening to changes
configSubscriber = new cote.Subscriber({ name: 'Config Lib : Subs', key: 'config' });
}
......@@ -46,9 +53,9 @@ exports.onChange = (name, filesToUncache = []) => {
logger.debug(`${JSON.stringify(config)}`);
global.config[name] = config;
let i = 0; const iMax = filesToUncache.length;
let i = 0; const iMax = pleaseUncache.length;
for (; i < iMax; i += 1) {
delete require.cache[require.resolve(filesToUncache)]; // clear file cache
delete require.cache[require.resolve(pleaseUncache[i])]; // clear file cache
}
}
});
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment