Also load custom CA file for "default"

This commit is contained in:
Adriaan Thomas
2015-11-17 13:31:40 +01:00
parent b7c19695e7
commit 15f8a30cd4
2 changed files with 13 additions and 11 deletions

View File

@@ -54,16 +54,18 @@ function loadCAs(caConfig) {
// If a ca file path has been specified, expand that here to the file's
// contents. As a user can specify these individually, we must load them
// one by one.
if (caConfig.search) {
caConfig.search = caConfig.search.map(function(s) {
return readCertFile(s);
});
}
['register', 'publish'].forEach(function(p) {
if (caConfig[p]) {
caConfig[p] = readCertFile(caConfig[p]);
for (var p in caConfig) {
if (caConfig.hasOwnProperty(p)) {
var prop = caConfig[p];
if (Array.isArray(prop)) {
caConfig[p] = prop.map(function(s) {
return readCertFile(s);
});
} else if (prop) {
caConfig[p] = readCertFile(prop);
}
}
});
}
}
Config.prototype.toObject = function () {

View File

@@ -120,7 +120,7 @@ describe('NPM Config on package.json', function () {
var config = require('../lib/Config')
.read(path.resolve('test/assets/custom-ca'));
['register', 'publish'].forEach(function (p) {
['register', 'publish', 'default'].forEach(function (p) {
assertCAContents(config.ca[p], 'config.ca.' + p);
});
@@ -136,7 +136,7 @@ describe('NPM Config on package.json', function () {
var config = require('../lib/Config')
.read(path.resolve('test/assets/custom-ca-embed'));
['register', 'publish'].forEach(function (p) {
['register', 'publish', 'default'].forEach(function (p) {
assertCAContents(config.ca[p], 'config.ca.' + p);
});