diff options
author | Julien Gilli <julien.gilli@joyent.com> | 2015-03-16 15:55:17 -0700 |
---|---|---|
committer | Julien Gilli <julien.gilli@joyent.com> | 2015-03-16 15:55:17 -0700 |
commit | ae58fc407f916b2abb164453a5b09273c543dbc3 (patch) | |
tree | 4a16fe73f996a54f34cfb553b2995d16c1375b7f /deps/npm/lib/help.js | |
parent | 2b64132101f179c30957e3c5f16fc47a8ec942e1 (diff) | |
parent | eb2764a9452baa7cba2d98dc34fa00fc776b0a12 (diff) | |
download | node-merge-review.tar.gz |
Merge remote-tracking branch 'upstream/v0.12'merge-review
Diffstat (limited to 'deps/npm/lib/help.js')
-rw-r--r-- | deps/npm/lib/help.js | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/deps/npm/lib/help.js b/deps/npm/lib/help.js index 07d921949..cb1d5715f 100644 --- a/deps/npm/lib/help.js +++ b/deps/npm/lib/help.js @@ -59,19 +59,23 @@ function help (args, cb) { var manroot = path.resolve(__dirname, "..", "man") // legacy - if (section === "global") - section = "folders" - else if (section === "json") - section = "package.json" + if (section === "global") section = "folders" + else if (section === "json") section = "package.json" // find either /section.n or /npm-section.n - var f = "+(npm-" + section + "|" + section + ").[0-9]" + var compext = "\\.+(gz|bz2|lzma|[FYzZ]|xz)$" + var f = "+(npm-" + section + "|" + section + ").[0-9]?(" + compext + ")" return glob(manroot + "/*/" + f, function (er, mans) { - if (er) - return cb(er) + if (er) return cb(er) + + if (!mans.length) return npm.commands["help-search"](args, cb) - if (!mans.length) - return npm.commands["help-search"](args, cb) + mans = mans.map(function (man) { + var ext = path.extname(man) + if (man.match(new RegExp(compext))) man = path.basename(man, ext) + + return man + }) viewMan(pickMan(mans, pref), cb) }) |