Merge remote-tracking branch 'refs/remotes/origin/master' into beta
This commit is contained in:
commit
0121c00a2c
|
@ -10,19 +10,47 @@ var fs = require('fs');
|
||||||
var readline = require('readline');
|
var readline = require('readline');
|
||||||
var util = require('util');
|
var util = require('util');
|
||||||
|
|
||||||
|
var _packageSplice;
|
||||||
|
var _importSplice;
|
||||||
|
var _functionSplice;
|
||||||
|
var _functionCallSplice;
|
||||||
|
|
||||||
var _discordPath;
|
var _discordPath;
|
||||||
var _appFolder = "/app";
|
var _appFolder = "/app";
|
||||||
var _appArchive = "/app.asar";
|
var _appArchive = "/app.asar";
|
||||||
var _packageJson = _appFolder + "/package.json";
|
var _packageJson = _appFolder + "/package.json";
|
||||||
var _index = _appFolder + "/app/index.js";
|
var _index = _appFolder + "/app/index.js";
|
||||||
|
|
||||||
|
var _force = false;
|
||||||
|
|
||||||
|
// Get Arguments
|
||||||
|
process.argv.forEach(function (val, index, array) {
|
||||||
|
if (val == "--force") {
|
||||||
|
_force = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (val == "-d" || val == "--directory") {
|
||||||
|
_discordPath = array[(index+1)]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
function install() {
|
function install() {
|
||||||
|
|
||||||
|
if (typeof _discordPath == 'undefined') {
|
||||||
var _os = process.platform;
|
var _os = process.platform;
|
||||||
if (_os == "win32") {
|
if (_os == "win32") {
|
||||||
|
_packageSplice = 10;
|
||||||
|
_importSplice = 83;
|
||||||
|
_functionCallSplice = 497;
|
||||||
|
_functionSplice = 597;
|
||||||
_discordPath = process.env.LOCALAPPDATA + "/Discord/app-"+dver+"/resources";
|
_discordPath = process.env.LOCALAPPDATA + "/Discord/app-"+dver+"/resources";
|
||||||
} else if (_os == "darwin") {
|
} else if (_os == "darwin") {
|
||||||
_discordPath = "/Applications/Discord.app/Contents/Resources/" // currently hardcoded to look in the Applications directory, will fix
|
_packageSplice = 10;
|
||||||
|
_importSplice = 83;
|
||||||
|
_functionCallSplice = 500;
|
||||||
|
_functionSplice = 602;
|
||||||
|
_discordPath = "/Applications/Discord.app/Contents/Resources" // Defaults to Applications directory
|
||||||
|
}
|
||||||
}
|
}
|
||||||
console.log("Looking for discord resources at: " + _discordPath);
|
console.log("Looking for discord resources at: " + _discordPath);
|
||||||
|
|
||||||
|
@ -68,9 +96,9 @@ function install() {
|
||||||
console.log("Injecting index.js");
|
console.log("Injecting index.js");
|
||||||
|
|
||||||
var data = fs.readFileSync(_discordPath + _index).toString().split("\n");
|
var data = fs.readFileSync(_discordPath + _index).toString().split("\n");
|
||||||
data.splice(83, 0, 'var _betterDiscord = require(\'betterdiscord\');\n');
|
data.splice(_importSplice, 0, 'var _betterDiscord = require(\'betterdiscord\');\n');
|
||||||
data.splice(497, 0, 'betterDiscord(mainWindow);');
|
data.splice(_functionCallSplice, 0, 'betterDiscord(mainWindow);');
|
||||||
data.splice(597, 0, 'function betterDiscord(mw) { _betterDiscord = new _betterDiscord.BetterDiscord(mw); _betterDiscord.init(); }');
|
data.splice(_functionSplice, 0, 'function betterDiscord(mw) { _betterDiscord = new _betterDiscord.BetterDiscord(mw); _betterDiscord.init(); }');
|
||||||
|
|
||||||
fs.writeFile(_discordPath + _index, data.join("\n"), function(err) {
|
fs.writeFile(_discordPath + _index, data.join("\n"), function(err) {
|
||||||
if(err) return console.log(err);
|
if(err) return console.log(err);
|
||||||
|
@ -79,7 +107,7 @@ function install() {
|
||||||
console.log("Injecting package.json");
|
console.log("Injecting package.json");
|
||||||
|
|
||||||
var data = fs.readFileSync(_discordPath + _packageJson).toString().split("\n");
|
var data = fs.readFileSync(_discordPath + _packageJson).toString().split("\n");
|
||||||
data.splice(10, 0, '"betterdiscord":"^0.1.2",');
|
data.splice(_packageSplice, 0, '"betterdiscord":"^0.1.2",');
|
||||||
|
|
||||||
fs.writeFile(_discordPath + _packageJson, data.join("\n"), function(err) {
|
fs.writeFile(_discordPath + _packageJson, data.join("\n"), function(err) {
|
||||||
if(err) return console.log(err);
|
if(err) return console.log(err);
|
||||||
|
@ -112,6 +140,7 @@ function init() {
|
||||||
|
|
||||||
var rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
var rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
||||||
|
|
||||||
|
if (_force == false) {
|
||||||
rl.question("The following directories will be deleted if they exists: discorpath/app, discordpath/node_modules/BetterDiscord, is this ok? Y/N", function(answer) {
|
rl.question("The following directories will be deleted if they exists: discorpath/app, discordpath/node_modules/BetterDiscord, is this ok? Y/N", function(answer) {
|
||||||
|
|
||||||
var alc = answer.toLowerCase();
|
var alc = answer.toLowerCase();
|
||||||
|
@ -131,6 +160,9 @@ function init() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
install();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
init();
|
init();
|
||||||
|
|
|
@ -19,7 +19,6 @@ var _mainWindow;
|
||||||
var _updater;
|
var _updater;
|
||||||
var _hash;
|
var _hash;
|
||||||
|
|
||||||
|
|
||||||
var _userDefault = {"cache": null};
|
var _userDefault = {"cache": null};
|
||||||
var _userConfig = {"cache": null};
|
var _userConfig = {"cache": null};
|
||||||
var _cacheExpired = false;
|
var _cacheExpired = false;
|
||||||
|
|
Loading…
Reference in New Issue