Blob Blame History Raw
From b187e18f9132794977df93b3a0604cb38a79fe27 Mon Sep 17 00:00:00 2001
From: Stephen Gallagher <sgallagh@redhat.com>
Date: Fri, 15 Jan 2016 14:24:49 -0500
Subject: [PATCH] Use system doc paths

---
 lib/help.js | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/lib/help.js b/lib/help.js
index a954ae814b7550b199c94685832da9fb446f0e15..ec0c38070be0f2ff8ade59a99cf776acd4a792b5 100644
--- a/lib/help.js
+++ b/lib/help.js
@@ -52,11 +52,11 @@ function help (args, cb) {
       return n !== argnum
     }))
   }
 
   // npm help <section>: Try to find the path
-  var manroot = path.resolve(__dirname, '..', 'man')
+  var manroot = path.resolve("/usr/share/man")
 
   // legacy
   if (section === 'global') section = 'folders'
   else if (section === 'json') section = 'package.json'
 
@@ -81,11 +81,11 @@ function help (args, cb) {
     viewMan(pickMan(mans, pref), cb)
   })
 }
 
 function pickMan (mans, pref_) {
-  var nre = /([0-9]+)$/
+  var nre = /([0-9]+)/
   var pref = {}
   pref_.forEach(function (sect, i) {
     pref[sect] = i
   })
   mans = mans.sort(function (a, b) {
@@ -97,21 +97,20 @@ function pickMan (mans, pref_) {
   })
   return mans[0]
 }
 
 function viewMan (man, cb) {
-  var nre = /([0-9]+)$/
+  var nre = /([0-9]+)/
   var num = man.match(nre)[1]
-  var section = path.basename(man, '.' + num)
+  var section = man
 
   // at this point, we know that the specified man page exists
   var manpath = path.join(__dirname, '..', 'man')
   var env = {}
   Object.keys(process.env).forEach(function (i) {
     env[i] = process.env[i]
   })
-  env.MANPATH = manpath
   var viewer = npm.config.get('viewer')
 
   var conf
   switch (viewer) {
     case 'woman':
@@ -150,11 +149,11 @@ function htmlMan (man) {
       sect = 'misc'
       break
     default:
       throw new Error('invalid man section: ' + sect)
   }
-  return path.resolve(__dirname, '..', 'html', 'doc', sect, f)
+  return path.resolve("/usr/share/", "npm", "html", "doc", sect, f)
 }
 
 function npmUsage (valid, cb) {
   npm.config.set('loglevel', 'silent')
   log.level = 'silent'
@@ -222,11 +221,11 @@ function wrap (arr) {
     })
   return out.join('\n    ').substr(2)
 }
 
 function getSections (cb) {
-  var g = path.resolve(__dirname, '../man/man[0-9]/*.[0-9]')
+  var g = path.resolve("/usr/share/man/man[0-9]/*.[0-9].gz")
   glob(g, function (er, files) {
     if (er) return cb(er)
 
     cb(null, Object.keys(files.reduce(function (acc, file) {
       file = path.basename(file).replace(/\.[0-9]+$/, '')
-- 
2.7.0