{} convention, logs, exit and hook skeleton

This commit is contained in:
Jiiks 2016-10-31 18:05:51 +02:00
parent fc53df5e4b
commit 7f5986aa01
1 changed files with 24 additions and 4 deletions

View File

@ -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: { } });