diff --git a/lib/cli.js b/lib/cli.js index 14f768e..40cbce8 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -198,8 +198,12 @@ CLI.prototype.init = function (opts, args, callback) { keyId: opts.keyId, insecure: opts.insecure }; - if (opts.insecure === undefined && process.env.SDC_TESTING) { - opts.insecure = common.boolFromString(process.env.SDC_TESTING); + // If --insecure not given, look at envvar(s) for that. + var specifiedInsecureOpt = opts._order.filter( + function (opt) { return opt.key === 'insecure'; }).length > 0; + if (!specifiedInsecureOpt && process.env.SDC_TESTING) { + opts.insecure = common.boolFromString(process.env.SDC_TESTING, + false, '"SDC_TESTING" envvar'); } if (opts.J) { envProfile.url = format('https://%s.api.joyent.com', opts.J); diff --git a/lib/common.js b/lib/common.js index ca5065f..7c77f05 100755 --- a/lib/common.js +++ b/lib/common.js @@ -50,7 +50,7 @@ function zeroPad(n, width) { * * @param value {Boolean|String} The input value to convert. * @param default_ {Boolean} The default value is `value` is undefined. - * @param errName {String} The variable name to quote in the possibly + * @param errName {String} The context to quote in the possibly * raised TypeError. */ function boolFromString(value, default_, errName) { @@ -63,8 +63,11 @@ function boolFromString(value, default_, errName) { } else if (typeof (value) === 'boolean') { return value; } else { - throw new TypeError( - format('invalid value for "%s": %j', errName, value)); + var errmsg = format('invalid boolean value: %j', value); + if (errName) { + errmsg = format('invalid boolean value for %s: %j', errName, value); + } + throw new TypeError(errmsg); } }