(logger, names, options, config)
| 4 | var defaultConfig = require('../config'); |
| 5 | |
| 6 | function uninstall(logger, names, options, config) { |
| 7 | if (!names.length) { |
| 8 | return new Q(); |
| 9 | } |
| 10 | |
| 11 | var project; |
| 12 | |
| 13 | options = options || {}; |
| 14 | config = defaultConfig(config); |
| 15 | project = new Project(config, logger); |
| 16 | |
| 17 | return project.getTree(options).spread(function(tree, flattened) { |
| 18 | // Uninstall nodes |
| 19 | return ( |
| 20 | project |
| 21 | .uninstall(names, options) |
| 22 | // Clean out non-shared uninstalled dependencies |
| 23 | .then(function(uninstalled) { |
| 24 | var names = Object.keys(uninstalled); |
| 25 | var children = []; |
| 26 | |
| 27 | // Grab the dependencies of packages that were uninstalled |
| 28 | mout.object.forOwn(flattened, function(node) { |
| 29 | if (names.indexOf(node.endpoint.name) !== -1) { |
| 30 | children.push.apply( |
| 31 | children, |
| 32 | mout.object.keys(node.dependencies) |
| 33 | ); |
| 34 | } |
| 35 | }); |
| 36 | |
| 37 | // Clean them! |
| 38 | return clean(project, children, uninstalled); |
| 39 | }) |
| 40 | ); |
| 41 | }); |
| 42 | } |
| 43 | |
| 44 | function clean(project, names, removed) { |
| 45 | removed = removed || {}; |
nothing calls this directly
no test coverage detected
searching dependent graphs…