Added OS X support, modified install.bat to make it somewhat more user friendly
This commit is contained in:
parent
9348865ec7
commit
234c0656dd
|
@ -11,14 +11,19 @@ var readline = require('readline');
|
||||||
var util = require('util');
|
var util = require('util');
|
||||||
|
|
||||||
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";
|
||||||
|
|
||||||
function install() {
|
function install() {
|
||||||
|
|
||||||
_discordPath = process.env.LOCALAPPDATA + "\\Discord\\app-"+dver+"\\resources";
|
var _os = process.platform;
|
||||||
|
if (_os == "win32") {
|
||||||
|
_discordPath = process.env.LOCALAPPDATA + "/Discord/app-"+dver+"/resources";
|
||||||
|
} else if (_os == "darwin") {
|
||||||
|
_discordPath = "/Applications/Discord.app/Contents/Resources/" // currently hardcoded to look in the Applications directory, will fix
|
||||||
|
}
|
||||||
console.log("Looking for discord resources at: " + _discordPath);
|
console.log("Looking for discord resources at: " + _discordPath);
|
||||||
|
|
||||||
fs.exists(_discordPath, function(exists) {
|
fs.exists(_discordPath, function(exists) {
|
||||||
|
@ -32,17 +37,17 @@ function install() {
|
||||||
console.log("Deleted " + _discordPath + _appFolder + " folder.");
|
console.log("Deleted " + _discordPath + _appFolder + " folder.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(fs.existsSync(_discordPath + "\\node_modules\\BetterDiscord")) {
|
if(fs.existsSync(_discordPath + "/node_modules/BetterDiscord")) {
|
||||||
console.log("Deleting " + _discordPath + "\\node_modules\\BetterDiscord" + " folder.");
|
console.log("Deleting " + _discordPath + "/node_modules/BetterDiscord" + " folder.");
|
||||||
wrench.rmdirSyncRecursive(_discordPath + "\\node_modules\\BetterDiscord");
|
wrench.rmdirSyncRecursive(_discordPath + "/node_modules/BetterDiscord");
|
||||||
console.log("Deleted " + _discordPath + "\\node_modules\\BetterDiscord" + " folder.");
|
console.log("Deleted " + _discordPath + "/node_modules/BetterDiscord" + " folder.");
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("Copying BetterDiscord");
|
console.log("Copying BetterDiscord");
|
||||||
|
|
||||||
fs.mkdirSync(_discordPath + "\\node_modules\\BetterDiscord");
|
fs.mkdirSync(_discordPath + "/node_modules/BetterDiscord");
|
||||||
|
|
||||||
wrench.copyDirSyncRecursive(__dirname + "\\BetterDiscord\\", _discordPath + "\\node_modules\\BetterDiscord\\", {forceDelete: true});
|
wrench.copyDirSyncRecursive(__dirname + "/BetterDiscord/", _discordPath + "/node_modules/BetterDiscord/", {forceDelete: true});
|
||||||
|
|
||||||
console.log("Looking for app archive");
|
console.log("Looking for app archive");
|
||||||
if(fs.existsSync(_discordPath + _appArchive)) {
|
if(fs.existsSync(_discordPath + _appArchive)) {
|
||||||
|
@ -64,8 +69,8 @@ function install() {
|
||||||
|
|
||||||
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(83, 0, 'var _betterDiscord = require(\'betterdiscord\');\n');
|
||||||
data.splice(497, 0, '_betterDiscord = new _betterDiscord.BetterDiscord(mainWindow); \n _betterDiscord.init(); \n');
|
data.splice(497, 0, 'betterDiscord(mainWindow);');
|
||||||
|
data.splice(597, 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);
|
||||||
|
@ -107,7 +112,7 @@ function init() {
|
||||||
|
|
||||||
var rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
var rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
||||||
|
|
||||||
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();
|
||||||
|
|
||||||
|
|
|
@ -1 +1,10 @@
|
||||||
cmd /k node.exe index.js
|
@echo off
|
||||||
|
where node.exe >nul 2>nul
|
||||||
|
if %errorlevel%==1 (
|
||||||
|
echo "Node.exe not found, opening your browser..."
|
||||||
|
start "" "https://nodejs.org/dist/latest/win-x86/node.exe"
|
||||||
|
pause
|
||||||
|
) else (
|
||||||
|
cmd /k node.exe index.js
|
||||||
|
)
|
||||||
|
exit
|
|
@ -0,0 +1,7 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# As there is no Linux support, this script assumes OS X as the host system.
|
||||||
|
|
||||||
|
command -v node > /dev/null || echo 'Node not found, please download it!' && open 'https://nodejs.org/en/' && sleep 5 && exit
|
||||||
|
|
||||||
|
node index.js
|
||||||
|
exit
|
Binary file not shown.
Loading…
Reference in New Issue