Merge pull request #24 from Candunc/master

Added some command line parameters for index.js
This commit is contained in:
Jiiks 2015-10-31 23:56:21 +02:00
commit c61323a577
2 changed files with 41 additions and 23 deletions

View File

@ -16,13 +16,28 @@ 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() {
var _os = process.platform; if (typeof _discordPath == 'undefined') {
if (_os == "win32") { var _os = process.platform;
_discordPath = process.env.LOCALAPPDATA + "/Discord/app-"+dver+"/resources"; if (_os == "win32") {
} else if (_os == "darwin") { _discordPath = process.env.LOCALAPPDATA + "/Discord/app-"+dver+"/resources";
_discordPath = "/Applications/Discord.app/Contents/Resources/" // currently hardcoded to look in the Applications directory, will fix } else if (_os == "darwin") {
_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);
@ -112,25 +127,29 @@ 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) { 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) {
var alc = answer.toLowerCase(); var alc = answer.toLowerCase();
switch(alc) { switch(alc) {
case "y": case "y":
install(); install();
break; break;
case "yes": case "yes":
install(); install();
break; break;
case "n": case "n":
process.exit(); process.exit();
break; break;
case "no": case "no":
process.exit(); process.exit();
break; break;
} }
}); });
} else {
install();
}
} }
init(); init();

View File

@ -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;