diff options
author | isaacs <i@izs.me> | 2010-08-25 06:30:20 +0400 |
---|---|---|
committer | isaacs <i@izs.me> | 2010-08-25 16:21:52 +0400 |
commit | f75f7585e2effb54b3837a4f6a4ca024d2f30823 (patch) | |
tree | 2f0f8c88a73aef40f577b53e234aeeb004c9deb4 | |
parent | 9d5d55cae10538b3c0b8b5aa93a61d26a22b3da3 (diff) |
Activate mans!
-rw-r--r-- | lib/activate.js | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/lib/activate.js b/lib/activate.js index 9a83cac27..2a4111f4a 100644 --- a/lib/activate.js +++ b/lib/activate.js @@ -30,7 +30,7 @@ function activate (args, cb) { asyncMap(args, preActivate, function (er, data) { log.silly(args, "preActivate over") if (er) return cb(er) - asyncMap(data, activate_, 4, function (er) { + asyncMap(data, activate_, 5, function (er) { if (er) return cb(er) asyncMap(data, postActivate, cb) }) @@ -50,6 +50,7 @@ function activate_ (data, cb) { shimIfExists(fromMain, toMain, cb) linkIfExists(fromLib, toLib, cb) linkBins(data, cb) + linkMans(data, cb) } function postActivate (data, cb) { @@ -96,11 +97,33 @@ function preActivate (arg, cb) { } ) } - +function linkMans (pkg, cb) { + log.verbose(pkg._id, "activate linkMans") + log.silly(pkg.man, "activate linkMans") + 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) + , manStem = path.join( manroot + , "man"+sxn + , (bn.indexOf(pkg.name) === 0 ? bn + : pkg.name + "-" + bn) + ) + , manSrc = manStem + "-" + pkg.version + "." + sxn + gz + , manDest = manStem + "." + sxn + gz + log.silly(manSrc, "manSrc") + log.silly(manDest, "manDest") + linkIfExists(manSrc, manDest, cb) + }, cb) +} function linkBins (pkg, cb) { log.verbose(pkg._id, "activate linkBins") log.silly(pkg.bin, "activate linkBins") - var binroot = npm.config.get('binroot') + var binroot = npm.config.get("binroot") if (!pkg.bin || !binroot) return cb() asyncMap(Object.keys(pkg.bin), function (i, cb) { var to = path.join(binroot, i) |