From ecaf4e4eab5d5a29e7903a9e3fa3663c8dbca790 Mon Sep 17 00:00:00 2001 From: Greg MacLellan Date: Mon, 16 Jun 2014 14:21:06 -0400 Subject: [PATCH] Require outputfile command line argument, display usage info if missing, and always make relative to script location --- ca-store-generator.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ca-store-generator.js b/ca-store-generator.js index 653028a..74f3299 100644 --- a/ca-store-generator.js +++ b/ca-store-generator.js @@ -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 ", process.argv[1]); + console.info(" where 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) {