-
Notifications
You must be signed in to change notification settings - Fork 8
/
detect-mac.js
37 lines (33 loc) · 1.12 KB
/
detect-mac.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
var defaultBrowserMac = require("default-browser-id");
var exec = require("child_process").exec;
module.exports = function (callback) {
defaultBrowserMac()
.then(function (browserId) {
var value = browserId;
var valueLC = value.toLowerCase();
/*
Safari com.apple.Safari
Google Chrome com.google.chrome
Opera com.operasoftware.Opera
Firefox org.mozilla.firefox
*/
var out = {
isIE: false,
isSafari: valueLC.indexOf("safari") > -1,
isFirefox: valueLC.indexOf("firefox") > -1,
isChrome: valueLC.indexOf("google") > -1,
isChromium: valueLC.indexOf("chromium") > -1, // untested
isOpera: valueLC.indexOf("opera") > -1,
identity: value,
};
out.isBlink = out.isChrome || out.isChromium || out.isOpera;
out.isWebkit = out.isSafari || out.isBlink;
out.commonName = require("./common-name")(out);
callback(null, out);
})
.catch(function (err) {
if (err) {
callback("Unable to retrieve default browser: " + err);
}
});
};