Sha256: b2af8b61840ceab8817651d3a35a11bc7ec05f85fcc78328818da39661b0f639

Contents?: true

Size: 1.34 KB

Versions: 62

Compression:

Stored size: 1.34 KB

Contents

var mout = require('mout');
var Project = require('../core/Project');
var defaultConfig = require('../config');

function prune(logger, options, config) {
    var project;

    options = options || {};
    config = defaultConfig(config);
    project = new Project(config, logger);

    return clean(project, options);
}

function clean(project, options, removed) {
    removed = removed || {};

    // Continually call clean until there is no more extraneous
    // dependencies to remove
    return project.getTree(options)
    .spread(function (tree, flattened, extraneous) {
        var names = extraneous.map(function (extra) {
            return extra.endpoint.name;
        });

        // Uninstall extraneous
        return project.uninstall(names, options)
        .then(function (uninstalled) {
            // Are we done?
            if (!mout.object.size(uninstalled)) {
                return removed;
            }

            // Not yet, recurse!
            mout.object.mixIn(removed, uninstalled);
            return clean(project, options, removed);
        });
    });
}

// -------------------

prune.readOptions = function (argv) {
    var cli = require('../util/cli');

    var options = cli.readOptions({
        'production': { type: Boolean, shorthand: 'p' },
    }, argv);

    delete options.argv;

    return [options];
};

module.exports = prune;

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
trusty-festivity-extension-2.6.3 node_modules/bower/lib/commands/prune.js
trusty-festivity-extension-2.6.2 node_modules/bower/lib/commands/prune.js
trusty-festivity-extension-2.6.1 node_modules/bower/lib/commands/prune.js
trusty-festivity-extension-2.6 node_modules/bower/lib/commands/prune.js
trusty-festivity-extension-2.5.19 node_modules/bower/lib/commands/prune.js
trusty-festivity-extension-2.5.18 node_modules/bower/lib/commands/prune.js
trusty-festivity-extension-2.5.17 node_modules/bower/lib/commands/prune.js
trusty-festivity-extension-2.5.16 node_modules/bower/lib/commands/prune.js
trusty-festivity-extension-2.5.15 node_modules/bower/lib/commands/prune.js
trusty-festivity-extension-2.5.14 node_modules/bower/lib/commands/prune.js
trusty-festivity-extension-2.5.13 node_modules/bower/lib/commands/prune.js
trusty-festivity-extension-2.5.12 node_modules/bower/lib/commands/prune.js
trusty-festivity-extension-2.5.11 node_modules/bower/lib/commands/prune.js
trusty-festivity-extension-2.5.10 node_modules/bower/lib/commands/prune.js
trusty-festivity-extension-2.5.9 node_modules/bower/lib/commands/prune.js
trusty-festivity-extension-2.5.8 node_modules/bower/lib/commands/prune.js
trusty-festivity-extension-2.5.7 node_modules/bower/lib/commands/prune.js
trusty-festivity-extension-2.5.6 node_modules/bower/lib/commands/prune.js
trusty-festivity-extension-2.5.5 node_modules/bower/lib/commands/prune.js
trusty-festivity-extension-2.5.4 node_modules/bower/lib/commands/prune.js