[cache] disable on dev

This commit is contained in:
Andrea Vos 2021-07-03 13:19:52 +02:00
parent 4a595c20ae
commit 1469c30157

View File

@ -9,6 +9,10 @@ export class CacheObject {
}
async fetch(generator) {
if (process.env.NODE_ENV === 'development') {
return await generator();
}
if (fs.existsSync(this.path) && fs.statSync(this.path).mtimeMs >= (new Date() - this.maxAgeMinutes*60*1000)) {
const content = fs.readFileSync(this.path);
return this.path.endsWith('.js') ? JSON.parse(content) : content;