Skip to content

Commit

Permalink
Don't print 'unbuild' on install
Browse files Browse the repository at this point in the history
Confusing to say 'this is being deleted' when that's the thing that
you're actually PUTTING there.  Only print the unbuilt pkg when it's
an explicit uninstall/unbuild command.
  • Loading branch information
isaacs committed Jul 11, 2013
1 parent 732f107 commit c8596f3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -1173,7 +1173,7 @@ function unpack (pkg, ver, unpackTarget, dMode, fMode, uid, gid, cb) {
log.error("unpack", "Could not read data for %s", pkg + "@" + ver)
return cb(er)
}
npm.commands.unbuild([unpackTarget], function (er) {
npm.commands.unbuild([unpackTarget], true, function (er) {
if (er) return cb(er)
tar.unpack( path.join(npm.cache, pkg, ver, "package.tgz")
, unpackTarget
Expand Down
2 changes: 1 addition & 1 deletion lib/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -982,7 +982,7 @@ function write (target, targetFolder, context, cb_) {
if (!er) return cb_(er, data)

if (false === npm.config.get("rollback")) return cb_(er)
npm.commands.unbuild([targetFolder], function (er2) {
npm.commands.unbuild([targetFolder], true, function (er2) {
if (er2) log.error("error rolling back", target._id, er2)
return cb_(er, data)
})
Expand Down
14 changes: 10 additions & 4 deletions lib/unbuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@ var readJson = require("read-package-json")

// args is a list of folders.
// remove any bins/etc, and then delete the folder.
function unbuild (args, cb) { asyncMap(args, unbuild_, cb) }
function unbuild (args, silent, cb) {
if (typeof silent === 'function') cb = silent, silent = false
asyncMap(args, unbuild_(silent), cb)
}

function unbuild_ (folder, cb) {
function unbuild_ (silent) { return function (folder, cb) {
folder = path.resolve(folder)
delete build._didBuild[folder]
log.info(folder, "unbuild")
Expand All @@ -28,12 +31,16 @@ function unbuild_ (folder, cb) {
chain
( [ [lifecycle, pkg, "preuninstall", folder, false, true]
, [lifecycle, pkg, "uninstall", folder, false, true]
, !silent && function(cb) {
console.log("unbuild " + pkg._id)
cb()
}
, [rmStuff, pkg, folder]
, [lifecycle, pkg, "postuninstall", folder, false, true]
, [rm, folder] ]
, cb )
})
}
}}

function rmStuff (pkg, folder, cb) {
// if it's global, and folder is in {prefix}/node_modules,
Expand All @@ -46,7 +53,6 @@ function rmStuff (pkg, folder, cb) {
readJson.cache.del(path.resolve(folder, "package.json"))

log.verbose([top, gnm, parent], "unbuild " + pkg._id)
console.log("unbuild " + pkg._id)
asyncMap([rmBins, rmMans], function (fn, cb) {
fn(pkg, folder, parent, top, cb)
}, cb)
Expand Down

0 comments on commit c8596f3

Please sign in to comment.