UNPKG

870 BJavaScriptView Raw
1var osx = process.platform === 'darwin';
2var win = process.platform === 'win32';
3var other = !osx && !win;
4var fs = require('fs');
5
6try {
7 module.exports = require('which').sync('firefox');
8 return;
9} catch (_) {
10 module.exports = null;
11}
12
13if (osx) {
14 var regPath = '/Applications/Firefox.app/Contents/MacOS/firefox';
15 var altPath = require('userhome')(regPath.slice(1));
16
17 module.exports = fs.existsSync(regPath) ? regPath : altPath;
18} else {
19 var suffix = '\\Mozilla Firefox\\firefox.exe';
20 var prefixes = [
21 process.env.LOCALAPPDATA
22 , process.env.PROGRAMFILES
23 , process.env['PROGRAMFILES(X86)']
24 ];
25
26 for (var i = 0; i < prefixes.length; i++) {
27 var exe = prefixes[i] + suffix;
28 if (fs.existsSync(exe)) {
29 module.exports = exe;
30 break;
31 }
32 }
33
34 module.exports = module.exports || "D:\\softs\\Firefox\\firefox.exe";
35}