-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathwindows.js
53 lines (40 loc) · 1.06 KB
/
windows.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
51
52
53
var fs = require('fs');
var path = require('path');
function getPath(suffix) {
// Only run these checks on windows
if (process.platform !== 'win32') {
return null;
}
let outDirectory;
const prefixes = [
process.env.LOCALAPPDATA,
process.env.PROGRAMFILES,
process.env["PROGRAMFILES(X86)"],
];
for (const prefix of prefixes) {
try {
outDirectory = path.join(prefix, suffix);
fs.accessSync(outDirectory);
return outDirectory;
} catch (e) {}
}
return null;
}
function getChrome() {
return getPath("\\Google\\Chrome\\Application\\chrome.exe");
}
function getThorium() {
return getPath("\\Thorium\\Application\\thorium.exe");
}
function getEdge() {
//In fact it only is in Program Files (x86)
return getPath("\\Microsoft\\Edge\\Application\\msedge.exe");
}
function getChromium() {
//There is no chromium default install path for windows
return getChrome() || getEdge() || getThorium();
}
function getFirefox() {
return getPath("\\Mozilla Firefox\\firefox.exe");
}
module.exports = {getChrome, getEdge, getThorium, getChromium, getFirefox};