diff options
author | isaacs <i@izs.me> | 2012-06-05 00:49:28 +0400 |
---|---|---|
committer | isaacs <i@izs.me> | 2012-06-05 00:49:28 +0400 |
commit | 9dd369c05a2f899725d4ca3070389061cbcc1e5e (patch) | |
tree | f94255f2f903845633d187c22c4b99c4c609a291 | |
parent | 5bdeead0b17dc995abde5710a4c25ea1891d8a00 (diff) |
Open bug/doc urls properly on windows
-rw-r--r-- | lib/bugs.js | 24 | ||||
-rw-r--r-- | lib/docs.js | 24 |
2 files changed, 36 insertions, 12 deletions
diff --git a/lib/bugs.js b/lib/bugs.js index 7982746cf..2a9352632 100644 --- a/lib/bugs.js +++ b/lib/bugs.js @@ -41,10 +41,22 @@ function bugs (args, cb) { } function open (url, cb) { - exec(npm.config.get("browser"), [url], log.er(cb, - "Failed to open "+url+" in a browser. It could be that the\n"+ - "'browser' config is not set. Try doing this:\n"+ - " npm config set browser google-chrome\n"+ - "or:\n"+ - " npm config set browser lynx\n")) + 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() } diff --git a/lib/docs.js b/lib/docs.js index 8af4c1bb6..20b110406 100644 --- a/lib/docs.js +++ b/lib/docs.js @@ -37,10 +37,22 @@ function docs (args, cb) { } function open (url, cb) { - exec(npm.config.get("browser"), [url], log.er(cb, - "Failed to open "+url+" in a browser. It could be that the\n"+ - "'browser' config is not set. Try doing this:\n"+ - " npm config set browser google-chrome\n"+ - "or:\n"+ - " npm config set browser lynx\n")) + 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() } |