Require outputfile command line argument, display usage info if missing, and always make relative to script location

This commit is contained in:
Greg MacLellan 2014-06-16 14:21:06 -04:00
parent b52fc86671
commit ecaf4e4eab
1 changed files with 8 additions and 4 deletions

View File

@ -147,12 +147,16 @@ function dumpCerts(certs, filename) {
console.info("Wrote '" + filename.replace(/'/g, "\\'") + "'.");
}
//Expects a filename as the second command line argument
var outputFile = process.argv[2];
if(outputFile == null) {
outputFile = path.join(__dirname, 'ssl-root-cas-latest.js');
if (process.argv[2] == null) {
console.error("Error: No file specified");
console.info("Usage: %s <outputfile>", process.argv[1]);
console.info(" where <outputfile> is the name of the file to write to, relative to %s", process.argv[1]);
process.exit(3);
}
//Expects a filename as the second command line argument; made relative to directory of this file
var outputFile = path.resolve(__dirname, process.argv[2]);
console.info("Loading latest certificates from " + CERTDB_URL);
request(CERTDB_URL, function (error, response, body) {
if (error) {