[bug][cache][banner] fix utf-8 conversion breaking banners

This commit is contained in:
Andrea 2021-12-24 16:08:27 +01:00
parent 9ce22edc9a
commit 8838bde509
1 changed files with 9 additions and 2 deletions

View File

@ -17,8 +17,15 @@ export class CacheObject {
} }
if (fs.existsSync(this.path) && fs.statSync(this.path).mtimeMs >= (new Date() - this.maxAgeMinutes*60*1000)) { if (fs.existsSync(this.path) && fs.statSync(this.path).mtimeMs >= (new Date() - this.maxAgeMinutes*60*1000)) {
const content = fs.readFileSync(this.path).toString('utf-8'); let content = fs.readFileSync(this.path);
return this.path.endsWith('.js') ? JSON.parse(content) : content; if (this.path.endsWith('.js') || this.path.endsWith('.txt')) {
content = content.toString('utf-8')
}
if (this.path.endsWith('.js')) {
content = JSON.parse(content);
}
return content;
} }
const result = await generator(); const result = await generator();