Skip to content

Commit

Permalink
Try to use xdg-open as a browser on Linux
Browse files Browse the repository at this point in the history
`xdg-open` is a command similar to `open` - it tries to find a preferred
command to open a resource with. However, it isn't present on some
machines (depending on window manager/desktop environment), thus we have
to check for it's existance with `which`.
  • Loading branch information
mmalecki committed Feb 13, 2012
1 parent 21b77a4 commit 50ed364
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lib/utils/config-defs.js
Expand Up @@ -4,6 +4,7 @@
var path = require("path")
, url = require("url")
, Stream = require("stream").Stream
, whichSync = require("which").sync
, semver = require("semver")
, stableFamily = semver.parse(process.version)
, os = require("os")
Expand Down Expand Up @@ -95,6 +96,14 @@ Object.defineProperty(exports, "defaults", {get: function () {
}
}

var browser = process.platform === "darwin" ? "open"
: process.platform === "win32" ? "start" : null;

if (process.platform === "linux") {
try { browser = whichSync("xdg-open") }
catch (_) { browser = "google-chrome" }
}

return defaults =
{ "always-auth" : false

Expand All @@ -114,10 +123,7 @@ Object.defineProperty(exports, "defaults", {get: function () {
+ os.release() )

// are there others?
, browser : process.platform === "darwin" ? "open"
: process.platform === "win32" ? "start"
: "google-chrome"

, browser : browser
, ca : // the npm CA certificate.
"-----BEGIN CERTIFICATE-----\n"+
"MIIChzCCAfACCQDauvz/KHp8ejANBgkqhkiG9w0BAQUFADCBhzELMAkGA1UEBhMC\n"+
Expand Down

0 comments on commit 50ed364

Please sign in to comment.