Sha256: b0803bf0b048dc549d0c536b3699feac0b70bbb0978bcda160ed4155114b6547

Contents?: true

Size: 1.35 KB

Versions: 7

Compression:

Stored size: 1.35 KB

Contents

var object = require('mout/object');
var lang = require('mout/lang');
var string = require('mout/string');

function camelCase(config) {
    var camelCased = {};

    // Camel case
    object.forOwn(config, function (value, key) {
        // Ignore null values
        if (value == null) {
            return;
        }

        key = string.camelCase(key.replace(/_/g, '-'));
        camelCased[key] = lang.isPlainObject(value) ? camelCase(value) : value;
    });

    return camelCased;
}

function expand(config) {
    config = camelCase(config);

    // Expand some properties
    // Registry
    if (typeof config.registry === 'string') {
        config.registry = {
            search: [config.registry],
            register: config.registry,
            publish: config.registry
        };
    } else if (config.registry) {
        if (config.registry.search && !Array.isArray(config.registry.search)) {
            config.registry.search = [config.registry.search];
        }
    }

    // CA
    if (typeof config.ca === 'string') {
        config.ca = {
            search: [config.ca],
            register: config.ca,
            publish: config.ca
        };
    } else if (config.ca) {
        if (config.ca.search && !Array.isArray(config.ca.search)) {
            config.ca.search = [config.ca.search];
        }
    }

    return config;
}

module.exports = expand;

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
entangled-0.0.16 spec/dummy/public/node_modules/bower/node_modules/bower-config/lib/util/expand.js
entangled-0.0.15 spec/dummy/public/node_modules/bower/node_modules/bower-config/lib/util/expand.js
entangled-0.0.14 spec/dummy/public/node_modules/bower/node_modules/bower-config/lib/util/expand.js
entangled-0.0.13 spec/dummy/public/node_modules/bower/node_modules/bower-config/lib/util/expand.js
entangled-0.0.12 spec/dummy/public/node_modules/bower/node_modules/bower-config/lib/util/expand.js
entangled-0.0.11 spec/dummy/public/node_modules/bower/node_modules/bower-config/lib/util/expand.js
entangled-0.0.10 spec/dummy/public/node_modules/bower/node_modules/bower-config/lib/util/expand.js