Fix: Plex errors #141

Merged
KevinMidboe merged 13 commits from fix/plex-errors into master 2022-08-25 15:28:29 +00:00
Showing only changes of commit 7bcf6923fe - Show all commits

View File

@@ -1,3 +1,4 @@
import fs from "fs";
import path from "path";
import { fileURLToPath } from "url";
@@ -10,8 +11,7 @@ const __dirname = path.dirname(__filename);
class Config {
constructor() {
this.location = Config.determineLocation();
// eslint-disable-next-line import/no-dynamic-require, global-require
this.fields = require(`${this.location}`);
this.fields = Config.readFileContents(this.location);
}
static getInstance() {
@@ -25,6 +25,17 @@ class Config {
return path.join(__dirname, "..", "..", process.env.SEASONED_CONFIG);
}
static readFileContents(location) {
let content = {};
try {
content = JSON.parse(fs.readFileSync(location, { encoding: "utf-8" }));
} catch (err) {
console.error(`Error loading configuration file at path: ${location}`);
}
return content;
}
get(section, option) {
if (
this.fields[section] === undefined ||