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 _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() {
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
if (typeof _discordPath == 'undefined') {
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" // Defaults to Applications directory
}
}
console.log("Looking for discord resources at: " + _discordPath);
@ -112,25 +127,29 @@ function init() {
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) {
case "y":
install();
break;
case "yes":
install();
break;
case "n":
process.exit();
break;
case "no":
process.exit();
break;
}
});
switch(alc) {
case "y":
install();
break;
case "yes":
install();
break;
case "n":
process.exit();
break;
case "no":
process.exit();
break;
}
});
} else {
install();
}
}
init();

View File

@ -19,7 +19,6 @@ var _mainWindow;
var _updater;
var _hash;
var _userDefault = {"cache": null};
var _userConfig = {"cache": null};
var _cacheExpired = false;