function normalizePluginsList(plugins) {
    // 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.slice(1).join('@');
        return {
            'name': name,
            'version': version // optional
        };
    });

    // 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
    _.each(DEFAULT_PLUGINS, function(plugin) {
        if (_.find(plugins, { name: plugin })) {
            return;
        }

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