diff options
Diffstat (limited to 'lib/docs.js')
-rw-r--r-- | lib/docs.js | 36 |
1 files changed, 4 insertions, 32 deletions
diff --git a/lib/docs.js b/lib/docs.js index 72c1869b9..ffa91aa6b 100644 --- a/lib/docs.js +++ b/lib/docs.js @@ -14,6 +14,7 @@ var exec = require("./utils/exec.js") , npm = require("./npm.js") , registry = npm.registry , log = require("npmlog") + , opener = require("opener") function docs (args, cb) { if (!args.length) return cb(docs.usage) @@ -22,37 +23,8 @@ function docs (args, cb) { if (er) return cb(er) var homepage = d.homepage , repo = d.repository || d.repositories - if (homepage) return open(homepage, cb) - if (repo) { - if (Array.isArray(repo)) repo = repo.shift() - if (repo.hasOwnProperty("url")) repo = repo.url - log.verbose("repository", repo) - if (repo) { - return open(repo.replace(/^git(@|:\/\/)/, 'http://') - .replace(/\.git$/, '')+"#readme", cb) - } - } - return open("http://search.npmjs.org/#/" + d.name, cb) + , url = homepage ? homepage + : "https://npmjs.org/package/" + d.name + opener(url, { command: npm.config.get("browser") }, cb) }) } - -function open (url, cb) { - var args = [url] - , browser = npm.config.get("browser") - - if (process.platform === "win32" && browser === "start") { - args = [ "/c", "start" ].concat(args) - browser = "cmd" - } - - if (!browser) { - var er = ["the 'browser' config is not set. Try doing this:" - ," npm config set browser google-chrome" - ,"or:" - ," npm config set browser lynx"].join("\n") - return cb(er) - } - - exec(browser, args, process.env, false, function () {}) - cb() -} |