Skip to content

Commit

Permalink
only specify npm.prefix as gentlyRm base when it is inside folder path
Browse files Browse the repository at this point in the history
  • Loading branch information
phated authored and othiym23 committed Jan 23, 2015
1 parent 4ad01ea commit 29a6ef3
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/unbuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]
Expand All @@ -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 )
})
}}
Expand Down

0 comments on commit 29a6ef3

Please sign in to comment.