diff options
author | Forrest L Norvell <forrest@npmjs.com> | 2015-02-27 03:46:03 +0300 |
---|---|---|
committer | Forrest L Norvell <forrest@npmjs.com> | 2015-02-27 04:05:51 +0300 |
commit | d3cb6e1ff82d8cae7610b6c0ad751913d09846b6 (patch) | |
tree | 25c1130e816ae3e53fdb20e827152e02578b80c3 /lib | |
parent | 50f461d248c4d22e881a9535dccc1d57d994dbc7 (diff) |
help: tweaks to compressed filename matching
Diffstat (limited to 'lib')
-rw-r--r-- | lib/help.js | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/lib/help.js b/lib/help.js index d2debadbf..cb1d5715f 100644 --- a/lib/help.js +++ b/lib/help.js @@ -59,25 +59,20 @@ 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 compext = "\.+(gz|bz2|lzma|[FYzZ]|xz)" + 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 (ext.match(compext)) - man = path.basename(man, ext) + if (man.match(new RegExp(compext))) man = path.basename(man, ext) return man }) |