diff options
author | isaacs <i@izs.me> | 2010-08-25 06:39:47 +0400 |
---|---|---|
committer | isaacs <i@izs.me> | 2010-08-25 16:21:52 +0400 |
commit | ab2298a9da88e640e7cf68e79df7e7ddebc62876 (patch) | |
tree | 85558b3a359420c261fd607308f3cb0076a66f7d | |
parent | f75f7585e2effb54b3837a4f6a4ca024d2f30823 (diff) |
Handle mans in deactivate/uninstall
-rw-r--r-- | lib/deactivate.js | 24 | ||||
-rw-r--r-- | lib/uninstall.js | 22 |
2 files changed, 42 insertions, 4 deletions
diff --git a/lib/deactivate.js b/lib/deactivate.js index 0af8c782b..8cf32faa6 100644 --- a/lib/deactivate.js +++ b/lib/deactivate.js @@ -18,7 +18,7 @@ function deactivate (args, cb) { return a.split("@").shift() }), preDeactivate, function (er, data) { if (er) return cb(er) - asyncMap(data, deactivate_, 4, function (er) { + asyncMap(data, deactivate_, 5, function (er) { if (er) return cb(er) asyncMap(data, postDeactivate, cb) }) @@ -34,6 +34,10 @@ function deactivate_ (data, cb) { rm(active, cb) rm(activeMain, cb) rm(activeLib, cb) + rmBins(data, cb) + rmMans(data, cb) +} +function rmBins (data, cb) { var binroot = npm.config.get("binroot") if (!data.bin || !binroot) return cb() asyncMap(Object.getOwnPropertyNames(data.bin) @@ -42,7 +46,23 @@ function deactivate_ (data, cb) { , cb ) } - +function rmMans (pkg, cb) { + var manroot = npm.config.get("manroot") + if (!pkg.man || !manroot) return cb() + asyncMap(pkg.man, function (man, cb) { + var parseMan = man.match(/(.*)\.([0-9]+)(\.gz)?$/) + , stem = parseMan[1] + , sxn = parseMan[2] + , gz = parseMan[3] || "" + , bn = path.basename(stem) + rm(path.join( manroot + , "man"+sxn + , (bn.indexOf(pkg.name) === 0 ? bn + : pkg.name + "-" + bn) + + "." + sxn + gz + ), cb) + }, cb) +} function preDeactivate (pkg, cb) { // run the "deactivate" lifecycle event diff --git a/lib/uninstall.js b/lib/uninstall.js index 72741ebcb..b5bc37993 100644 --- a/lib/uninstall.js +++ b/lib/uninstall.js @@ -133,10 +133,11 @@ function secondPart (args, cb) { removeLinkedDeps(arg, cb) log.verbose("remove bins", "uninstall "+arg._id) removeBins(arg, cb) + rmMans(arg, cb) log.verbose("remove public modules", "uninstall "+arg._id) rm(path.join(npm.root, arg.name+"-"+arg.version), cb) rm(path.join(npm.root, arg.name+"-"+arg.version+".js"), cb) - }, 5 ] + }, 6 ] , [ lifecycle, arg, "postuninstall" ] , [ log.verbose, "remove package dir", "uninstall "+arg._id] , [ rm, path.join(npm.dir, arg.name, arg.version) ] @@ -155,7 +156,24 @@ function secondPart (args, cb) { c.push(cb) chain(c) } - +function rmMans (pkg, cb) { + var manroot = npm.config.get("manroot") + if (!pkg.man || !manroot) return cb() + asyncMap(pkg.man, function (man, cb) { + var parseMan = man.match(/(.*)\.([0-9]+)(\.gz)?$/) + , stem = parseMan[1] + , sxn = parseMan[2] + , gz = parseMan[3] || "" + , bn = path.basename(stem) + rm(path.join( manroot + , "man"+sxn + , (bn.indexOf(pkg.name) === 0 ? bn + : pkg.name + "-" + bn) + + "-" + pkg.version + + "." + sxn + gz + ), cb) + }, cb) +} function removeBins (data, cb) { if (!data.bin) return cb() var binroot = npm.config.get("binroot") |