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() {
if (typeof _discordPath == 'undefined') {
var _os = process.platform; var _os = process.platform;
if (_os == "win32") { if (_os == "win32") {
_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 _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,6 +127,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 +147,9 @@ function init() {
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;