diff --git a/v2/lib/core.js b/v2/lib/core.js index 7b0d9d7f..c9d792dc 100644 --- a/v2/lib/core.js +++ b/v2/lib/core.js @@ -13,16 +13,16 @@ const _fs = require('fs'), _config = require('./config.json'), - {_utils} = require('./utils'), - {_logger} = require('./utils'), - {EOL} = require('os'), + { _utils } = require('./utils'), + { _logger } = require('./utils'), + { EOL } = require('os'), _os = require('os'); const _startDate = new Date(); var _cfg; -//Default configs if for some reason we don't receive config params +// 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/', @@ -32,6 +32,8 @@ const _defaults = { class Core { constructor(args) { + this.continue = true; + _logger.log(`v${this.__version} Loading - OS: ${_os.platform()}`); this.initConfig(args.cfg); } @@ -42,6 +44,24 @@ class Core { _cfg.emotesEnabled = args.emotesEnabled || _defaults.emotesEnabled; } + hook(mainWindow) { + if(mainWindow === undefined) { + this.exit("mainWindow is undefined!"); + return; + } + } + + exit(reason, severity) { + this.continue = false; + // TODO show an actual error dialog for user + _logger.log(`Quitting. Reason: ${reason}`, severity || 2); + _logger.save(); + } + + get __version() { + return _config.core.version; + } + } exports.BetterDiscord = new Core({ cfg: { } }); \ No newline at end of file