aboutsummaryrefslogtreecommitdiff
path: root/deps/npm/lib/install/action/remove.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/lib/install/action/remove.js')
-rw-r--r--deps/npm/lib/install/action/remove.js16
1 files changed, 10 insertions, 6 deletions
diff --git a/deps/npm/lib/install/action/remove.js b/deps/npm/lib/install/action/remove.js
index 9fe77c35e0..a852d10c5f 100644
--- a/deps/npm/lib/install/action/remove.js
+++ b/deps/npm/lib/install/action/remove.js
@@ -7,6 +7,8 @@ var mkdirp = require('mkdirp')
var npm = require('../../npm.js')
var andIgnoreErrors = require('../and-ignore-errors.js')
var move = require('../../utils/move.js')
+var isInside = require('path-is-inside')
+var vacuum = require('fs-vacuum')
// This is weird because we want to remove the module but not it's node_modules folder
// allowing for this allows us to not worry about the order of operations
@@ -20,18 +22,20 @@ module.exports = function (staging, pkg, log, next) {
}
function removeLink (pkg, next) {
- npm.commands.unbuild(pkg.path, true, next)
+ var base = isInside(pkg.path, npm.prefix) ? npm.prefix : pkg.path
+ rimraf(pkg.path, (err) => {
+ if (err) return next(err)
+ vacuum(pkg.path, {base: base}, next)
+ })
}
function removeDir (pkg, log, next) {
var modpath = path.join(path.dirname(pkg.path), '.' + path.basename(pkg.path) + '.MODULES')
- move(path.join(pkg.path, 'node_modules'), modpath, unbuildPackage)
+ move(path.join(pkg.path, 'node_modules'), modpath).then(unbuildPackage, unbuildPackage)
function unbuildPackage (moveEr) {
- npm.commands.unbuild(pkg.path, true, function () {
- rimraf(pkg.path, moveEr ? andRemoveEmptyParents(pkg.path) : moveModulesBack)
- })
+ rimraf(pkg.path, moveEr ? andRemoveEmptyParents(pkg.path) : moveModulesBack)
}
function andRemoveEmptyParents (path) {
@@ -58,7 +62,7 @@ function removeDir (pkg, log, next) {
var to = path.join(pkg.path, 'node_modules', file)
// we ignore errors here, because they can legitimately happen, for instance,
// bundled modules will be in both node_modules folders
- move(from, to, andIgnoreErrors(done))
+ move(from, to).then(andIgnoreErrors(done), andIgnoreErrors(done))
}, cleanup)
}