forked from albertopasqualetto/browser-paths
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwindows.js
More file actions
49 lines (37 loc) · 973 Bytes
/
windows.js
File metadata and controls
49 lines (37 loc) · 973 Bytes
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
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 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();
}
function getFirefox() {
return getPath("\\Mozilla Firefox\\firefox.exe");
}
module.exports = {getChrome, getEdge, getChromium, getFirefox};