From e77ade9b8517248c58fc34dcaa5da5907cf9307b Mon Sep 17 00:00:00 2001 From: Andy Tudhope Date: Sun, 24 Dec 2017 11:38:30 +0200 Subject: [PATCH] Change order of logic Changed the way the `if` statement that looks at the package.json and the options passed in by the start script so that it gives precedence to the options set in `scripts/start`. Also added in the option to override the name, seeing as specifying the name in the `package.json` is severely limited by the need to have no spaces or capitalized letters. --- cli.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/cli.js b/cli.js index c138143..1ee67b2 100755 --- a/cli.js +++ b/cli.js @@ -69,11 +69,11 @@ function getCurrentPackageData() { var obj = {}; if (fs.existsSync(process.cwd() + '/package.json')) { var json = JSON.parse(fs.readFileSync(process.cwd() + '/package.json', 'utf8')); - obj["name"] = json.name; - obj["whisper-identity"] = "dapp-" + fromAscii(json.name); - obj["dapp-url"] = json["dapp-url"] || cli.dappUrl; - obj["bot-url"] = json["bot-url"] || cli.botUrl; - obj["photo-path"] = json["photo-path"] || cli.photoPath; + obj["name"] = cli.name || json.name; + obj["whisper-identity"] = cli.whisperIdentity || "dapp-" + fromAscii(json.name) ; + obj["dapp-url"] = cli.dappUrl || json["dapp-url"]; + obj["bot-url"] = cli.botUrl || json["bot-url"]; + obj["photo-path"] = cli.photoPath || json["photo-path"]; } return obj; } @@ -312,6 +312,7 @@ cli.on("*", function(command) { cli.version(pkgJson.version) .option("--ip [ip]", "IP address of your device") + .option("--name [name]", "Name overrides package.json seeing as spaces and caps aren't available there") .option("--dappUrl [url]", "Custom DApp URL (overrides the one from the package.json)") .option("--botUrl [url]", "Custom bot URL (overrides the one from the package.json)") .option("--photoPath [url]", "Custom photo for DApp (overrides the one from the package.json)")