From debc39559987a9831ca95d2217f6d005f6a6fed4 Mon Sep 17 00:00:00 2001 From: Jia Hao Date: Sun, 5 Jul 2015 15:10:36 +0800 Subject: [PATCH] Validation of url should trigger after the check for the required arguments --- cli.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/cli.js b/cli.js index 54c0d79..c68a959 100755 --- a/cli.js +++ b/cli.js @@ -17,23 +17,24 @@ if (protocolSchemes && protocolNames && protocolNames.length === protocolSchemes }) } - -if (!validator.isURL(args.target)) { - console.error('Enter a valid target url'); - process.exit(1); -} - if (!args.dir || !args.name || !args.version || !args.target || (!args.all && (!args.platform || !args.arch))) { console.error(usage); process.exit(1); } + +if (!validator.isURL(args.target)) { + console.error('Enter a valid target url'); + process.exit(1); +} + +// writes parameters for the app into a text file +// I'm not exactly sure how to pass these as an argument through code var appArgs = { name: args.name, targetUrl: args.target }; - fs.writeFileSync('./app/targetUrl.txt', JSON.stringify(appArgs));