From b8793fd2b601ea3407cd08056342fc554bf99b79 Mon Sep 17 00:00:00 2001 From: Jiiks Date: Thu, 7 Mar 2019 21:09:48 +0200 Subject: [PATCH] Package parsing for production --- core/src/main.js | 20 ++++++++++++++++++-- core/src/modules/config.js | 10 +++++++++- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/core/src/main.js b/core/src/main.js index adc76f13..eab5fa26 100644 --- a/core/src/main.js +++ b/core/src/main.js @@ -218,8 +218,10 @@ export class BetterDiscord { this.config.compatibility(); this.bindings(); - this.parseClientPackage(); this.extraPaths(); + this.parseClientPackage(); + this.parseEditorPackage(); + this.parseCorePackage(); this.database.init(); configProxy = () => this.config; @@ -289,7 +291,7 @@ export class BetterDiscord { */ parseClientPackage() { const clientPath = this.config.getPath('client'); - const clientPkg = TESTS ? require(`${path.resolve(clientPath, '..')}/package.json`) :require(`${clientPath}/package.json`); + const clientPkg = TESTS ? require(`${path.resolve(clientPath, '..')}/package.json`) : require(`${clientPath}/package.json`); const { version } = clientPkg; const main = TESTS ? 'betterdiscord.client.js' : clientPkg.main; this.config.addPath('client_script', `${clientPath}/${main}`); @@ -297,6 +299,20 @@ export class BetterDiscord { console.log(`[BetterDiscord] Client v${this.config.clientVersion} - ${this.config.getPath('client_script')}`); } + parseCorePackage() { + const corePath = this.config.getPath('core'); + const corePkg = TESTS ? require(`${path.resolve(corePath, '..')}/package.json`) : require(`${corePath}/package.json`); + const { version } = corePkg; + this.config.setCoreVersion(version); + } + + parseEditorPackage() { + const editorPath = this.config.getPath('editor'); + const editorPkg = TESTS ? require(`${path.resolve(editorPath, '..')}/package.json`) : require(`${editorPath}/package.json`); + const { version } = editorPkg; + this.config.setEditorVersion(version); + } + /** * Add extra paths to config */ diff --git a/core/src/modules/config.js b/core/src/modules/config.js index 23ae6179..43559729 100644 --- a/core/src/modules/config.js +++ b/core/src/modules/config.js @@ -37,7 +37,15 @@ export default class Config extends Module { } setClientVersion(clientVersion) { - this.args.clientVersion = clientVersion; + this.state.clientVersion = clientVersion; + } + + setCoreVersion(coreVersion) { + this.state.coreVersion = coreVersion; + } + + setEditorVersion(editorVersion) { + this.state.editorVersion = editorVersion; } get paths() {