Paths for plugins and themes

This commit is contained in:
Jiiks 2018-01-11 14:37:52 +02:00
parent 5ec53510be
commit 38c61484c1
2 changed files with 36 additions and 14 deletions

30
core/dist/main.js vendored
View File

@ -17,9 +17,14 @@ function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, a
*/ */
const __DEV = { const __DEV = {
TESTING: false, TESTING: false,
clietScriptPath: "G:/Github/JsSucks/BetterDiscordApp/client/dist/betterdiscord.client.js" clientScriptPath: 'G:/Github/JsSucks/BetterDiscordApp/client/dist/betterdiscord.client.js'
}; };
const path = require('path');
const __pluginPath = path.resolve(__dirname, '..', '..', 'tests', 'plugins');
const __themePath = path.resolve(__dirname, '..', '..', 'tests', 'themes');
const { Utils, FileUtils, BDIpc, Config, WindowUtils } = require('./modules'); const { Utils, FileUtils, BDIpc, Config, WindowUtils } = require('./modules');
const { BrowserWindow } = require('electron'); const { BrowserWindow } = require('electron');
@ -27,9 +32,11 @@ const Common = {};
const dummyArgs = { const dummyArgs = {
'version': '0.3.1', 'version': '0.3.1',
'paths': [{ 'base': 'basePath' }, { 'plugins': 'pluginsPath' }, { 'themes': 'themesPath' }] 'paths': [{ 'base': 'basePath' }, { 'plugins': __pluginPath }, { 'themes': __themePath }]
}; };
console.log(dummyArgs);
class Comms { class Comms {
constructor() { constructor() {
@ -62,9 +69,12 @@ class Comms {
class BetterDiscord { class BetterDiscord {
constructor(args) { constructor(args) {
this.injectScripts = this.injectScripts.bind(this);
Common.Config = new Config(args || dummyArgs); Common.Config = new Config(args || dummyArgs);
this.comms = new Comms(); this.comms = new Comms();
this.init(); this.init();
console.log("PLUGINS PATH:");
console.log(dummyArgs.paths.plugins);
} }
init() { init() {
@ -75,14 +85,12 @@ class BetterDiscord {
_this.windowUtils = new WindowUtils({ window }); _this.windowUtils = new WindowUtils({ window });
_this.windowUtils.webContents.on('did-finish-load', function (e) { _this.windowUtils.webContents.on('did-finish-load', function (e) {
if (__DEV) { return _this.injectScripts(true);
_this.windowUtils.injectScript(__DEV.clietScriptPath);
}
}); });
setTimeout(function () { setTimeout(function () {
if (__DEV) { if (__DEV) {
_this.windowUtils.injectScript(__DEV.clietScriptPath); _this.injectScripts();
} }
}, 500); }, 500);
})(); })();
@ -98,18 +106,22 @@ class BetterDiscord {
clearInterval(defer); clearInterval(defer);
return; return;
} }
//TODO Check for Discord loading finished
if (windows.length === 1 && windows[0].webContents.getURL().includes("discordapp.com")) { if (windows.length === 1 && windows[0].webContents.getURL().includes("discordapp.com")) {
resolve(windows[0]); resolve(windows[0]);
clearInterval(defer); clearInterval(defer);
} }
//resolve(windows[0]);
//clearInterval(defer);
}, 100); }, 100);
}); });
})(); })();
} }
injectScripts(reload = false) {
if (__DEV) {
this.windowUtils.injectScript(__DEV.clientScriptPath);
}
}
get fileUtils() { get fileUtils() {
return FileUtils; return FileUtils;
} }

View File

@ -14,9 +14,14 @@
*/ */
const __DEV = { const __DEV = {
TESTING: false, TESTING: false,
clientScriptPath: "G:/Github/JsSucks/BetterDiscordApp/client/dist/betterdiscord.client.js" clientScriptPath: 'G:/Github/JsSucks/BetterDiscordApp/client/dist/betterdiscord.client.js'
} }
const path = require('path');
const __pluginPath = path.resolve(__dirname, '..', '..', 'tests', 'plugins');
const __themePath = path.resolve(__dirname, '..', '..', 'tests', 'themes');
const { Utils, FileUtils, BDIpc, Config, WindowUtils } = require('./modules'); const { Utils, FileUtils, BDIpc, Config, WindowUtils } = require('./modules');
const { BrowserWindow } = require('electron'); const { BrowserWindow } = require('electron');
@ -26,11 +31,14 @@ const dummyArgs = {
'version': '0.3.1', 'version': '0.3.1',
'paths': [ 'paths': [
{ 'base': 'basePath' }, { 'base': 'basePath' },
{ 'plugins': 'pluginsPath' }, { 'plugins': __pluginPath },
{ 'themes': 'themesPath' } { 'themes': __themePath }
] ]
}; };
console.log(dummyArgs);
class Comms { class Comms {
constructor() { constructor() {
@ -65,6 +73,8 @@ class BetterDiscord {
Common.Config = new Config(args || dummyArgs); Common.Config = new Config(args || dummyArgs);
this.comms = new Comms(); this.comms = new Comms();
this.init(); this.init();
console.log("PLUGINS PATH:");
console.log(dummyArgs.paths.plugins);
} }
async init() { async init() {
@ -75,7 +85,7 @@ class BetterDiscord {
setTimeout(() => { setTimeout(() => {
if (__DEV) { if (__DEV) {
this.ínjectScripts(); this.injectScripts();
} }
}, 500); }, 500);
} }
@ -98,7 +108,7 @@ class BetterDiscord {
}); });
} }
injectScripts(reload) { injectScripts(reload = false) {
if (__DEV) { if (__DEV) {
this.windowUtils.injectScript(__DEV.clientScriptPath); this.windowUtils.injectScript(__DEV.clientScriptPath);
} }