-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmacos.js
50 lines (39 loc) · 1.08 KB
/
macos.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
38
39
40
41
42
43
44
45
46
47
48
49
50
var fs = require('fs');
var path = require('path');
function testPath(defaultPath) {
if (process.platform !== "darwin") {
return null;
}
try {
let homePath = path.join(process.env.HOME, defaultPath);
fs.accessSync(homePath);
return homePath;
} catch (e) {
try {
fs.accessSync(defaultPath);
return defaultPath;
} catch (err) {
return null;
}
}
}
function getChrome() {
return testPath("/Applications/Google Chrome.app/Contents/MacOS/Google Chrome");
}
function getEdge() {
return testPath("/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge");
}
function getSafari() {
return testPath("/Applications/Safari.app/Contents/MacOS/Safari");
}
function getThorium() {
return testPath("/Applications/Thorium.app/Contents/MacOS/Thorium");
}
function getChromium() {
//There is no chromium default install path for windows
return getChrome() || getEdge() || getThorium();
}
function getFirefox() {
return testPath("/Applications/Firefox.app/Contents/MacOS/firefox");
}
module.exports = { getChrome, getEdge, getThorium, getChromium, getFirefox, getSafari };