Validation of url should trigger after the check for the required arguments

This commit is contained in:
Jia Hao 2015-07-05 15:10:36 +08:00
parent 0939715017
commit debc395599
1 changed files with 8 additions and 7 deletions

15
cli.js
View File

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