lib/configuration.js
function normalizePluginsList(plugins, addDefaults) {
    // Normalize list to an array
    plugins = _.isString(plugins) ? plugins.split(',') : (plugins || []);

    // Remove empty parts
    plugins = _.compact(plugins);

    // Divide as {name, version} to handle format like 'myplugin@1.0.0'
    plugins = _.map(plugins, function(plugin) {
        if (plugin.name) return plugin;

        var parts = plugin.split('@');
        var name = parts[0];
        var version = parts[1];
        return {
            'name': name,
            'version': version, // optional
            'isDefault': isDefaultPlugin(name, version)
        };
    });

    // List plugins to remove
    var toremove = _.chain(plugins)
    .filter(function(plugin) {
        return plugin.name.length > 0 && plugin.name[0] == '-';
    })
    .map(function(plugin) {
        return plugin.name.slice(1);
    })
    .value();

    // Merge with defaults
    if (addDefaults !== false) {
        _.each(DEFAULT_PLUGINS, function(plugin) {
            if (_.find(plugins, { name: plugin })) {
                return;
            }

            plugins.push({
                'name': plugin,
                'isDefault': true
            });
        });
    }

    // Remove plugin that start with '-'
    plugins = _.filter(plugins, function(plugin) {
        return !_.contains(toremove, plugin.name) && !(plugin.name.length > 0 && plugin.name[0] == '-');
    });

    // Remove duplicates
    plugins = _.uniq(plugins, 'name');

    return plugins;
}
function normalizePluginsList(plugins, addDefaults) {
    // Normalize list to an array
    plugins = _.isString(plugins) ? plugins.split(',') : (plugins || []);

    // Remove empty parts
    plugins = _.compact(plugins);

    // Divide as {name, version} to handle format like 'myplugin@1.0.0'
    plugins = _.map(plugins, function(plugin) {
        if (plugin.name) return plugin;

        var parts = plugin.split('@');
        var name = parts[0];
        var version = parts[1];
        return {
            'name': name,
            'version': version, // optional
            'isDefault': isDefaultPlugin(name, version)
        };
    });

    // List plugins to remove
    var toremove = _.chain(plugins)
    .filter(function(plugin) {
        return plugin.name.length > 0 && plugin.name[0] == '-';
    })
    .map(function(plugin) {
        return plugin.name.slice(1);
    })
    .value();

    // Merge with defaults
    if (addDefaults !== false) {
        _.each(DEFAULT_PLUGINS, function(plugin) {
            if (_.find(plugins, { name: plugin })) {
                return;
            }

            plugins.push({
                'name': plugin,
                'isDefault': true
            });
        });
    }

    // Remove plugin that start with '-'
    plugins = _.filter(plugins, function(plugin) {
        return !_.contains(toremove, plugin.name) && !(plugin.name.length > 0 && plugin.name[0] == '-');
    });

    // Remove duplicates
    plugins = _.uniq(plugins, 'name');

    return plugins;
}
function normalizePluginsList ( plugins , addDefaults ) { // Normalize list to an array plugins = _ . isString ( plugins ) ? plugins . split ( ',' ) : ( plugins || [ ] ) ; // Remove empty parts plugins = _ . compact ( plugins ) ; // Divide as {name, version} to handle format like 'myplugin@1.0.0' plugins = _ . map ( plugins , function ( plugin ) { if ( plugin . name ) return plugin ; var parts = plugin . split ( '@' ) ; var name = parts [ 0 ] ; var version = parts [ 1 ] ; return { 'name' : name , 'version' : version , // optional 'isDefault' : isDefaultPlugin ( name , version ) } ; } ) ; // List plugins to remove var toremove = _ . chain ( plugins ) . filter ( function ( plugin ) { return plugin . name . length > 0 && plugin . name [ 0 ] == '-' ; } ) . map ( function ( plugin ) { return plugin . name . slice ( 1 ) ; } ) . value ( ) ; // Merge with defaults if ( addDefaults !== false ) { _ . each ( DEFAULT_PLUGINS , function ( plugin ) { if ( _ . find ( plugins , { name : plugin } ) ) { return ; } plugins . push ( { 'name' : plugin , 'isDefault' : true } ) ; } ) ; } // Remove plugin that start with '-' plugins = _ . filter ( plugins , function ( plugin ) { return ! _ . contains ( toremove , plugin . name ) && ! ( plugin . name . length > 0 && plugin . name [ 0 ] == '-' ) ; } ) ; // Remove duplicates plugins = _ . uniq ( plugins , 'name' ) ; return plugins ; }
Normalize a list of plugins to use
Normalize a list of plugins to use