From fc53df5e4bd5ae27665f60b4834b9818e9b85349 Mon Sep 17 00:00:00 2001 From: Jiiks Date: Mon, 31 Oct 2016 17:57:12 +0200 Subject: [PATCH] Default configs --- v2/lib/config.json | 3 +++ v2/lib/core.js | 19 ++++++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/v2/lib/config.json b/v2/lib/config.json index 41605e5..1c828dd 100644 --- a/v2/lib/config.json +++ b/v2/lib/config.json @@ -4,5 +4,8 @@ }, "Core": { "Version": "0.3.0" + }, + "cfg": { + } } \ No newline at end of file diff --git a/v2/lib/core.js b/v2/lib/core.js index 9834ad0..7b0d9d7 100644 --- a/v2/lib/core.js +++ b/v2/lib/core.js @@ -15,24 +15,33 @@ const _config = require('./config.json'), {_utils} = require('./utils'), {_logger} = require('./utils'), - {EOL} = require('os'); + {EOL} = require('os'), + _os = require('os'); const _startDate = new Date(); var _cfg; -const _defaults = {}; +//Default configs if for some reason we don't receive config params +const _defaults = { + installPath: (_os.platform() === 'win32' ? process.env.APPDATA : _os.platform() === 'darwin' ? `${process.env.HOME}/Library/Preferences`: `/var/local`) + '/BetterDiscord/lib/', + dataPath: (_os.platform() === 'win32' ? process.env.APPDATA : _os.platform() === 'darwin' ? `${process.env.HOME}/Library/Preferences`: `/var/local`) + '/BetterDiscord/data/', + emotesEnabled: true +}; class Core { constructor(args) { - + this.initConfig(args.cfg); } initConfig(args) { - + _cfg = _config.cfg; + _cfg.installPath = args.installPath || _defaults.installPath; + _cfg.dataPath = args.dataPath || _defaults.dataPath; + _cfg.emotesEnabled = args.emotesEnabled || _defaults.emotesEnabled; } } -exports.BetterDiscord = new Core(null); \ No newline at end of file +exports.BetterDiscord = new Core({ cfg: { } }); \ No newline at end of file