diff --git a/lib/unbuild.js b/lib/unbuild.js index df57c5b346313..ede8482c40c3b 100644 --- a/lib/unbuild.js +++ b/lib/unbuild.js @@ -5,6 +5,7 @@ var readJson = require("read-package-json") , gentlyRm = require("./utils/gently-rm.js") , npm = require("./npm.js") , path = require("path") + , isInside = require("path-is-inside") , lifecycle = require("./utils/lifecycle.js") , asyncMap = require("slide").asyncMap , chain = require("slide").chain @@ -23,11 +24,12 @@ function unbuild_ (silent) { return function (folder, cb_) { cb_(er, path.relative(npm.root, folder)) } folder = path.resolve(folder) + var base = isInside(folder, npm.prefix) ? npm.prefix : folder delete build._didBuild[folder] log.verbose("unbuild", folder.substr(npm.prefix.length + 1)) readJson(path.resolve(folder, "package.json"), function (er, pkg) { // if no json, then just trash it, but no scripts or whatever. - if (er) return gentlyRm(folder, false, npm.prefix, cb) + if (er) return gentlyRm(folder, false, base, cb) readJson.cache.del(folder) chain ( [ [lifecycle, pkg, "preuninstall", folder, false, true] @@ -38,7 +40,7 @@ function unbuild_ (silent) { return function (folder, cb_) { } , [rmStuff, pkg, folder] , [lifecycle, pkg, "postuninstall", folder, false, true] - , [gentlyRm, folder, false, npm.prefix] ] + , [gentlyRm, folder, false, base] ] , cb ) }) }}