Fix handling of SDC_TESTING envvar
This commit is contained in:
parent
5e3efa02a6
commit
1b2ed0758e
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user