firefox-location2 1.0.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +170 -19
- package/bin.js +6 -0
- package/dist/index.cjs +83 -20
- package/dist/index.d.ts +19 -1
- package/dist/index.js +83 -20
- package/package.json +24 -9
package/README.md
CHANGED
|
@@ -1,35 +1,186 @@
|
|
|
1
|
-
[npm-image]: https://img.shields.io/npm/v/firefox-location2.svg
|
|
2
|
-
[npm-url]: https://npmjs.
|
|
3
|
-
[
|
|
4
|
-
[
|
|
5
|
-
[
|
|
6
|
-
[
|
|
7
|
-
|
|
8
|
-
# firefox-location2 [![npm][npm-image]][npm-url] [![workflow][action-image]][action-url] [![downloads][downloads-image]][downloads-url]
|
|
1
|
+
[npm-version-image]: https://img.shields.io/npm/v/firefox-location2.svg?color=FF7139
|
|
2
|
+
[npm-version-url]: https://www.npmjs.com/package/firefox-location2
|
|
3
|
+
[npm-downloads-image]: https://img.shields.io/npm/dm/firefox-location2.svg?color=2ecc40
|
|
4
|
+
[npm-downloads-url]: https://www.npmjs.com/package/firefox-location2
|
|
5
|
+
[action-image]: https://github.com/cezaraugusto/firefox-location2/actions/workflows/ci.yml/badge.svg?branch=main
|
|
6
|
+
[action-url]: https://github.com/cezaraugusto/firefox-location2/actions
|
|
9
7
|
|
|
10
8
|
> Approximates the current location of the Firefox browser across platforms.
|
|
11
9
|
|
|
12
|
-
#
|
|
10
|
+
# firefox-location2 [![Version][npm-version-image]][npm-version-url] [![Downloads][npm-downloads-image]][npm-downloads-url] [![workflow][action-image]][action-url]
|
|
11
|
+
|
|
12
|
+
<img alt="Firefox" align="right" src="https://cdn.jsdelivr.net/gh/extension-js/media@db5deb23fbfa85530f8146718812972998e13a4d/browser_logos/svg/firefox.svg" width="10.5%" />
|
|
13
|
+
|
|
14
|
+
* Finds Firefox in the following channel order: `stable` / `esr` / `developer edition` / `nightly`.
|
|
15
|
+
* Supports macOS / Windows / Linux
|
|
16
|
+
* Works both as an ES module or CommonJS
|
|
17
|
+
|
|
18
|
+
## Support table
|
|
19
|
+
|
|
20
|
+
This table lists the default locations where Firefox is typically installed for each supported platform and channel. The package checks these paths (in order) and returns the first one found.
|
|
21
|
+
|
|
22
|
+
<table>
|
|
23
|
+
<thead>
|
|
24
|
+
<tr>
|
|
25
|
+
<th>Platform</th>
|
|
26
|
+
<th>Channel</th>
|
|
27
|
+
<th>Paths checked</th>
|
|
28
|
+
</tr>
|
|
29
|
+
</thead>
|
|
30
|
+
<tbody>
|
|
31
|
+
<tr>
|
|
32
|
+
<td rowspan="4" align="center"><img alt="" width="64" height="64" src="https://cdn.jsdelivr.net/gh/extension-js/media@db5deb23fbfa85530f8146718812972998e13a4d/platform_logos/macos.png" /><br><strong>macOS</strong></td>
|
|
33
|
+
<td align="center">Firefox (Stable)</td>
|
|
34
|
+
<td>
|
|
35
|
+
<ul>
|
|
36
|
+
<li><code>/Applications/Firefox.app/Contents/MacOS/firefox</code></li>
|
|
37
|
+
<li><code>~/Applications/Firefox.app/Contents/MacOS/firefox</code></li>
|
|
38
|
+
</ul>
|
|
39
|
+
</td>
|
|
40
|
+
</tr>
|
|
41
|
+
<tr>
|
|
42
|
+
<td align="center">Firefox ESR</td>
|
|
43
|
+
<td>
|
|
44
|
+
<ul>
|
|
45
|
+
<li><code>/Applications/Firefox ESR.app/Contents/MacOS/firefox</code></li>
|
|
46
|
+
<li><code>~/Applications/Firefox ESR.app/Contents/MacOS/firefox</code></li>
|
|
47
|
+
</ul>
|
|
48
|
+
</td>
|
|
49
|
+
</tr>
|
|
50
|
+
<tr>
|
|
51
|
+
<td align="center">Firefox Developer Edition</td>
|
|
52
|
+
<td>
|
|
53
|
+
<ul>
|
|
54
|
+
<li><code>/Applications/Firefox Developer Edition.app/Contents/MacOS/firefox</code></li>
|
|
55
|
+
<li><code>~/Applications/Firefox Developer Edition.app/Contents/MacOS/firefox</code></li>
|
|
56
|
+
</ul>
|
|
57
|
+
</td>
|
|
58
|
+
</tr>
|
|
59
|
+
<tr>
|
|
60
|
+
<td align="center">Firefox Nightly</td>
|
|
61
|
+
<td>
|
|
62
|
+
<ul>
|
|
63
|
+
<li><code>/Applications/Firefox Nightly.app/Contents/MacOS/firefox</code></li>
|
|
64
|
+
<li><code>~/Applications/Firefox Nightly.app/Contents/MacOS/firefox</code></li>
|
|
65
|
+
</ul>
|
|
66
|
+
</td>
|
|
67
|
+
</tr>
|
|
68
|
+
<tr>
|
|
69
|
+
<td rowspan="4" align="center"><img alt="" width="64" height="64" src="https://cdn.jsdelivr.net/gh/extension-js/media@db5deb23fbfa85530f8146718812972998e13a4d/platform_logos/windows.png" /><br><strong>Windows</strong></td>
|
|
70
|
+
<td align="center">Firefox (Stable)</td>
|
|
71
|
+
<td>
|
|
72
|
+
<ul>
|
|
73
|
+
<li><code>%LOCALAPPDATA%\\Mozilla Firefox\\firefox.exe</code></li>
|
|
74
|
+
<li><code>%PROGRAMFILES%\\Mozilla Firefox\\firefox.exe</code></li>
|
|
75
|
+
<li><code>%PROGRAMFILES(X86)%\\Mozilla Firefox\\firefox.exe</code></li>
|
|
76
|
+
</ul>
|
|
77
|
+
</td>
|
|
78
|
+
</tr>
|
|
79
|
+
<tr>
|
|
80
|
+
<td align="center">Firefox ESR</td>
|
|
81
|
+
<td>
|
|
82
|
+
<ul>
|
|
83
|
+
<li><code>%LOCALAPPDATA%\\Mozilla Firefox ESR\\firefox.exe</code></li>
|
|
84
|
+
<li><code>%PROGRAMFILES%\\Mozilla Firefox ESR\\firefox.exe</code></li>
|
|
85
|
+
<li><code>%PROGRAMFILES(X86)%\\Mozilla Firefox ESR\\firefox.exe</code></li>
|
|
86
|
+
</ul>
|
|
87
|
+
</td>
|
|
88
|
+
</tr>
|
|
89
|
+
<tr>
|
|
90
|
+
<td align="center">Firefox Developer Edition</td>
|
|
91
|
+
<td>
|
|
92
|
+
<ul>
|
|
93
|
+
<li><code>%LOCALAPPDATA%\\Mozilla Firefox Developer Edition\\firefox.exe</code></li>
|
|
94
|
+
<li><code>%PROGRAMFILES%\\Mozilla Firefox Developer Edition\\firefox.exe</code></li>
|
|
95
|
+
<li><code>%PROGRAMFILES(X86)%\\Mozilla Firefox Developer Edition\\firefox.exe</code></li>
|
|
96
|
+
</ul>
|
|
97
|
+
</td>
|
|
98
|
+
</tr>
|
|
99
|
+
<tr>
|
|
100
|
+
<td align="center">Firefox Nightly</td>
|
|
101
|
+
<td>
|
|
102
|
+
<ul>
|
|
103
|
+
<li><code>%LOCALAPPDATA%\\Firefox Nightly\\firefox.exe</code></li>
|
|
104
|
+
<li><code>%PROGRAMFILES%\\Firefox Nightly\\firefox.exe</code></li>
|
|
105
|
+
<li><code>%PROGRAMFILES(X86)%\\Firefox Nightly\\firefox.exe</code></li>
|
|
106
|
+
</ul>
|
|
107
|
+
</td>
|
|
108
|
+
</tr>
|
|
109
|
+
<tr>
|
|
110
|
+
<td rowspan="5" align="center"><img alt="" width="64" height="64" src="https://cdn.jsdelivr.net/gh/extension-js/media@db5deb23fbfa85530f8146718812972998e13a4d/platform_logos/linux.png" /><br><strong>Linux/other</strong></td>
|
|
111
|
+
<td align="center">Firefox (Stable)</td>
|
|
112
|
+
<td>
|
|
113
|
+
<ul>
|
|
114
|
+
<li><code>firefox</code> (on <code>$PATH</code>)</li>
|
|
115
|
+
</ul>
|
|
116
|
+
</td>
|
|
117
|
+
</tr>
|
|
118
|
+
<tr>
|
|
119
|
+
<td align="center">Firefox ESR</td>
|
|
120
|
+
<td>
|
|
121
|
+
<ul>
|
|
122
|
+
<li><code>firefox-esr</code> (on <code>$PATH</code>)</li>
|
|
123
|
+
</ul>
|
|
124
|
+
</td>
|
|
125
|
+
</tr>
|
|
126
|
+
<tr>
|
|
127
|
+
<td align="center">Firefox Developer Edition</td>
|
|
128
|
+
<td>
|
|
129
|
+
<ul>
|
|
130
|
+
<li><code>firefox-developer-edition</code> / <code>firefox-devedition</code> (on <code>$PATH</code>)</li>
|
|
131
|
+
</ul>
|
|
132
|
+
</td>
|
|
133
|
+
</tr>
|
|
134
|
+
<tr>
|
|
135
|
+
<td align="center">Firefox Nightly</td>
|
|
136
|
+
<td>
|
|
137
|
+
<ul>
|
|
138
|
+
<li><code>firefox-nightly</code> (on <code>$PATH</code>)</li>
|
|
139
|
+
</ul>
|
|
140
|
+
</td>
|
|
141
|
+
</tr>
|
|
142
|
+
<tr>
|
|
143
|
+
<td align="center">Common locations</td>
|
|
144
|
+
<td>
|
|
145
|
+
<ul>
|
|
146
|
+
<li><code>/usr/bin/firefox</code></li>
|
|
147
|
+
<li><code>/usr/local/bin/firefox</code></li>
|
|
148
|
+
<li><code>/snap/bin/firefox</code> (Snap)</li>
|
|
149
|
+
<li><code>/opt/firefox/firefox</code></li>
|
|
150
|
+
</ul>
|
|
151
|
+
</td>
|
|
152
|
+
</tr>
|
|
153
|
+
</tbody>
|
|
154
|
+
</table>
|
|
155
|
+
|
|
156
|
+
Returns the first existing path found, or <code>null</code> if none are found.
|
|
157
|
+
|
|
158
|
+
Note: On Linux, the module first tries to resolve binaries on <code>$PATH</code> (using <code>which</code>) for the common channels listed above, then falls back to checking common filesystem locations like <code>/usr/bin/firefox</code>, <code>/usr/local/bin/firefox</code>, <code>/snap/bin/firefox</code>, and <code>/opt/firefox/firefox</code>.
|
|
159
|
+
|
|
160
|
+
## Usage
|
|
13
161
|
|
|
14
162
|
**Via Node.js:**
|
|
15
163
|
|
|
16
164
|
```js
|
|
17
|
-
|
|
18
|
-
import firefoxLocation from 'firefox-location2'
|
|
165
|
+
import firefoxLocation from "firefox-location2";
|
|
19
166
|
|
|
20
|
-
|
|
21
|
-
console.log(firefoxLocation())
|
|
167
|
+
console.log(firefoxLocation());
|
|
22
168
|
// /Applications/Firefox.app/Contents/MacOS/firefox
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
**Via CLI:**
|
|
23
172
|
|
|
24
|
-
|
|
25
|
-
|
|
173
|
+
```bash
|
|
174
|
+
npx firefox-location2
|
|
175
|
+
# /Applications/Firefox.app/Contents/MacOS/firefox
|
|
26
176
|
```
|
|
27
177
|
|
|
28
|
-
##
|
|
178
|
+
## Planned enhancements
|
|
29
179
|
|
|
30
|
-
-
|
|
31
|
-
-
|
|
32
|
-
-
|
|
180
|
+
- Flatpak detection on Linux: detect installed Flatpak app <code>org.mozilla.firefox</code> and expose the appropriate invocation.
|
|
181
|
+
- Custom build locations: probe common custom paths such as <code>~/bin/firefox</code>, <code>~/Downloads/firefox/firefox</code>, <code>/usr/local/firefox/firefox</code>, <code>/opt/firefox-dev/firefox</code>.
|
|
182
|
+
- Optional binary validation: helper to return <code>firefox --version</code> (or Flatpak equivalent) for diagnostics.
|
|
183
|
+
- Optional launch helpers: generate safe args (e.g., <code>--no-remote</code>, <code>--new-instance</code>, <code>-profile</code>, optional <code>-start-debugger-server</code>), with Flatpak-specific sandbox flags when applicable.
|
|
33
184
|
|
|
34
185
|
## Related projects
|
|
35
186
|
|
package/bin.js
ADDED
package/dist/index.cjs
CHANGED
|
@@ -43,36 +43,99 @@ const external_os_namespaceObject = require("os");
|
|
|
43
43
|
var external_os_default = /*#__PURE__*/ __webpack_require__.n(external_os_namespaceObject);
|
|
44
44
|
const external_which_namespaceObject = require("which");
|
|
45
45
|
var external_which_default = /*#__PURE__*/ __webpack_require__.n(external_which_namespaceObject);
|
|
46
|
-
|
|
47
|
-
const
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
46
|
+
function locateFirefox(deps) {
|
|
47
|
+
const f = (null == deps ? void 0 : deps.fs) ?? external_fs_default();
|
|
48
|
+
const w = (null == deps ? void 0 : deps.which) ?? external_which_default();
|
|
49
|
+
const o = (null == deps ? void 0 : deps.os) ?? external_os_default();
|
|
50
|
+
const p = (null == deps ? void 0 : deps.path) ?? external_path_default();
|
|
51
|
+
const env = (null == deps ? void 0 : deps.env) ?? process.env;
|
|
52
|
+
const platform = (null == deps ? void 0 : deps.platform) ?? process.platform;
|
|
53
|
+
const osx = 'darwin' === platform;
|
|
54
|
+
const win = 'win32' === platform;
|
|
55
|
+
const other = !osx && !win;
|
|
56
|
+
if (other) {
|
|
57
|
+
const candidates = [
|
|
58
|
+
'firefox',
|
|
59
|
+
'firefox-esr',
|
|
60
|
+
'firefox-developer-edition',
|
|
61
|
+
'firefox-devedition',
|
|
62
|
+
'firefox-nightly'
|
|
63
|
+
];
|
|
64
|
+
for (const cmd of candidates)try {
|
|
65
|
+
const resolved = w.sync(cmd);
|
|
66
|
+
if (resolved) return resolved;
|
|
67
|
+
} catch (_) {}
|
|
68
|
+
const linuxPaths = [
|
|
69
|
+
'/usr/bin/firefox',
|
|
70
|
+
'/usr/local/bin/firefox',
|
|
71
|
+
'/usr/lib/firefox/firefox',
|
|
72
|
+
'/snap/bin/firefox',
|
|
73
|
+
'/opt/firefox/firefox',
|
|
74
|
+
'/usr/local/firefox/firefox',
|
|
75
|
+
p.join(o.homedir(), 'bin', 'firefox'),
|
|
76
|
+
p.join(o.homedir(), 'Downloads', 'firefox', 'firefox'),
|
|
77
|
+
p.join(o.homedir(), '.local', 'share', 'flatpak', 'exports', 'bin', 'org.mozilla.firefox'),
|
|
78
|
+
'/var/lib/flatpak/exports/bin/org.mozilla.firefox'
|
|
79
|
+
];
|
|
80
|
+
for (const linuxPath of linuxPaths)if (f.existsSync(linuxPath)) return linuxPath;
|
|
53
81
|
return null;
|
|
54
82
|
}
|
|
55
83
|
if (osx) {
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
84
|
+
const apps = [
|
|
85
|
+
{
|
|
86
|
+
app: 'Firefox.app',
|
|
87
|
+
exec: 'firefox'
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
app: 'Firefox ESR.app',
|
|
91
|
+
exec: 'firefox'
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
app: 'Firefox Developer Edition.app',
|
|
95
|
+
exec: 'firefox'
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
app: 'Firefox Nightly.app',
|
|
99
|
+
exec: 'firefox'
|
|
100
|
+
}
|
|
101
|
+
];
|
|
102
|
+
const systemBase = '/Applications';
|
|
103
|
+
const userBase = p.join(o.homedir(), 'Applications');
|
|
104
|
+
for (const { app, exec } of apps){
|
|
105
|
+
const systemPath = `${systemBase}/${app}/Contents/MacOS/${exec}`;
|
|
106
|
+
if (f.existsSync(systemPath)) return systemPath;
|
|
107
|
+
const userPath = `${userBase}/${app}/Contents/MacOS/${exec}`;
|
|
108
|
+
if (f.existsSync(userPath)) return userPath;
|
|
109
|
+
}
|
|
110
|
+
return null;
|
|
59
111
|
}
|
|
60
112
|
{
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
113
|
+
const prefixes = [
|
|
114
|
+
env.LOCALAPPDATA,
|
|
115
|
+
env.PROGRAMFILES,
|
|
116
|
+
env['PROGRAMFILES(X86)']
|
|
117
|
+
].filter(Boolean);
|
|
118
|
+
const suffixes = [
|
|
119
|
+
p.join('Mozilla Firefox', 'firefox.exe'),
|
|
120
|
+
p.join('Mozilla Firefox ESR', 'firefox.exe'),
|
|
121
|
+
p.join('Mozilla Firefox Developer Edition', 'firefox.exe'),
|
|
122
|
+
p.join('Firefox Nightly', 'firefox.exe')
|
|
66
123
|
];
|
|
67
|
-
for (const prefix of
|
|
68
|
-
const exePath =
|
|
69
|
-
if (
|
|
124
|
+
for (const prefix of prefixes)for (const suffix of suffixes){
|
|
125
|
+
const exePath = p.join(prefix, suffix);
|
|
126
|
+
if (f.existsSync(exePath)) return exePath;
|
|
70
127
|
}
|
|
71
128
|
const defaultPaths = [
|
|
72
129
|
'C:\\Program Files\\Mozilla Firefox\\firefox.exe',
|
|
73
|
-
'C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe'
|
|
130
|
+
'C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe',
|
|
131
|
+
'C:\\Program Files\\Mozilla Firefox ESR\\firefox.exe',
|
|
132
|
+
'C:\\Program Files (x86)\\Mozilla Firefox ESR\\firefox.exe',
|
|
133
|
+
'C:\\Program Files\\Mozilla Firefox Developer Edition\\firefox.exe',
|
|
134
|
+
'C:\\Program Files (x86)\\Mozilla Firefox Developer Edition\\firefox.exe',
|
|
135
|
+
'C:\\Program Files\\Firefox Nightly\\firefox.exe',
|
|
136
|
+
'C:\\Program Files (x86)\\Firefox Nightly\\firefox.exe'
|
|
74
137
|
];
|
|
75
|
-
for (const defaultPath of defaultPaths)if (
|
|
138
|
+
for (const defaultPath of defaultPaths)if (f.existsSync(defaultPath)) return defaultPath;
|
|
76
139
|
return null;
|
|
77
140
|
}
|
|
78
141
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1,19 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type FsLike = {
|
|
2
|
+
existsSync: (p: string) => boolean;
|
|
3
|
+
};
|
|
4
|
+
export type WhichLike = {
|
|
5
|
+
sync: (cmd: string) => string;
|
|
6
|
+
};
|
|
7
|
+
export type Deps = {
|
|
8
|
+
fs?: FsLike;
|
|
9
|
+
which?: WhichLike;
|
|
10
|
+
os?: {
|
|
11
|
+
homedir: () => string;
|
|
12
|
+
};
|
|
13
|
+
path?: {
|
|
14
|
+
join: (...parts: string[]) => string;
|
|
15
|
+
};
|
|
16
|
+
env?: NodeJS.ProcessEnv;
|
|
17
|
+
platform?: NodeJS.Platform;
|
|
18
|
+
};
|
|
19
|
+
export default function locateFirefox(deps?: Deps): string | null;
|
package/dist/index.js
CHANGED
|
@@ -2,36 +2,99 @@ import * as __WEBPACK_EXTERNAL_MODULE_fs__ from "fs";
|
|
|
2
2
|
import * as __WEBPACK_EXTERNAL_MODULE_path__ from "path";
|
|
3
3
|
import * as __WEBPACK_EXTERNAL_MODULE_os__ from "os";
|
|
4
4
|
import * as __WEBPACK_EXTERNAL_MODULE_which__ from "which";
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
function locateFirefox(deps) {
|
|
6
|
+
const f = (null == deps ? void 0 : deps.fs) ?? __WEBPACK_EXTERNAL_MODULE_fs__["default"];
|
|
7
|
+
const w = (null == deps ? void 0 : deps.which) ?? __WEBPACK_EXTERNAL_MODULE_which__["default"];
|
|
8
|
+
const o = (null == deps ? void 0 : deps.os) ?? __WEBPACK_EXTERNAL_MODULE_os__["default"];
|
|
9
|
+
const p = (null == deps ? void 0 : deps.path) ?? __WEBPACK_EXTERNAL_MODULE_path__["default"];
|
|
10
|
+
const env = (null == deps ? void 0 : deps.env) ?? process.env;
|
|
11
|
+
const platform = (null == deps ? void 0 : deps.platform) ?? process.platform;
|
|
12
|
+
const osx = 'darwin' === platform;
|
|
13
|
+
const win = 'win32' === platform;
|
|
14
|
+
const other = !osx && !win;
|
|
15
|
+
if (other) {
|
|
16
|
+
const candidates = [
|
|
17
|
+
'firefox',
|
|
18
|
+
'firefox-esr',
|
|
19
|
+
'firefox-developer-edition',
|
|
20
|
+
'firefox-devedition',
|
|
21
|
+
'firefox-nightly'
|
|
22
|
+
];
|
|
23
|
+
for (const cmd of candidates)try {
|
|
24
|
+
const resolved = w.sync(cmd);
|
|
25
|
+
if (resolved) return resolved;
|
|
26
|
+
} catch (_) {}
|
|
27
|
+
const linuxPaths = [
|
|
28
|
+
'/usr/bin/firefox',
|
|
29
|
+
'/usr/local/bin/firefox',
|
|
30
|
+
'/usr/lib/firefox/firefox',
|
|
31
|
+
'/snap/bin/firefox',
|
|
32
|
+
'/opt/firefox/firefox',
|
|
33
|
+
'/usr/local/firefox/firefox',
|
|
34
|
+
p.join(o.homedir(), 'bin', 'firefox'),
|
|
35
|
+
p.join(o.homedir(), 'Downloads', 'firefox', 'firefox'),
|
|
36
|
+
p.join(o.homedir(), '.local', 'share', 'flatpak', 'exports', 'bin', 'org.mozilla.firefox'),
|
|
37
|
+
'/var/lib/flatpak/exports/bin/org.mozilla.firefox'
|
|
38
|
+
];
|
|
39
|
+
for (const linuxPath of linuxPaths)if (f.existsSync(linuxPath)) return linuxPath;
|
|
12
40
|
return null;
|
|
13
41
|
}
|
|
14
42
|
if (osx) {
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
43
|
+
const apps = [
|
|
44
|
+
{
|
|
45
|
+
app: 'Firefox.app',
|
|
46
|
+
exec: 'firefox'
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
app: 'Firefox ESR.app',
|
|
50
|
+
exec: 'firefox'
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
app: 'Firefox Developer Edition.app',
|
|
54
|
+
exec: 'firefox'
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
app: 'Firefox Nightly.app',
|
|
58
|
+
exec: 'firefox'
|
|
59
|
+
}
|
|
60
|
+
];
|
|
61
|
+
const systemBase = '/Applications';
|
|
62
|
+
const userBase = p.join(o.homedir(), 'Applications');
|
|
63
|
+
for (const { app, exec } of apps){
|
|
64
|
+
const systemPath = `${systemBase}/${app}/Contents/MacOS/${exec}`;
|
|
65
|
+
if (f.existsSync(systemPath)) return systemPath;
|
|
66
|
+
const userPath = `${userBase}/${app}/Contents/MacOS/${exec}`;
|
|
67
|
+
if (f.existsSync(userPath)) return userPath;
|
|
68
|
+
}
|
|
69
|
+
return null;
|
|
18
70
|
}
|
|
19
71
|
{
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
72
|
+
const prefixes = [
|
|
73
|
+
env.LOCALAPPDATA,
|
|
74
|
+
env.PROGRAMFILES,
|
|
75
|
+
env['PROGRAMFILES(X86)']
|
|
76
|
+
].filter(Boolean);
|
|
77
|
+
const suffixes = [
|
|
78
|
+
p.join('Mozilla Firefox', 'firefox.exe'),
|
|
79
|
+
p.join('Mozilla Firefox ESR', 'firefox.exe'),
|
|
80
|
+
p.join('Mozilla Firefox Developer Edition', 'firefox.exe'),
|
|
81
|
+
p.join('Firefox Nightly', 'firefox.exe')
|
|
25
82
|
];
|
|
26
|
-
for (const prefix of
|
|
27
|
-
const exePath =
|
|
28
|
-
if (
|
|
83
|
+
for (const prefix of prefixes)for (const suffix of suffixes){
|
|
84
|
+
const exePath = p.join(prefix, suffix);
|
|
85
|
+
if (f.existsSync(exePath)) return exePath;
|
|
29
86
|
}
|
|
30
87
|
const defaultPaths = [
|
|
31
88
|
'C:\\Program Files\\Mozilla Firefox\\firefox.exe',
|
|
32
|
-
'C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe'
|
|
89
|
+
'C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe',
|
|
90
|
+
'C:\\Program Files\\Mozilla Firefox ESR\\firefox.exe',
|
|
91
|
+
'C:\\Program Files (x86)\\Mozilla Firefox ESR\\firefox.exe',
|
|
92
|
+
'C:\\Program Files\\Mozilla Firefox Developer Edition\\firefox.exe',
|
|
93
|
+
'C:\\Program Files (x86)\\Mozilla Firefox Developer Edition\\firefox.exe',
|
|
94
|
+
'C:\\Program Files\\Firefox Nightly\\firefox.exe',
|
|
95
|
+
'C:\\Program Files (x86)\\Firefox Nightly\\firefox.exe'
|
|
33
96
|
];
|
|
34
|
-
for (const defaultPath of defaultPaths)if (
|
|
97
|
+
for (const defaultPath of defaultPaths)if (f.existsSync(defaultPath)) return defaultPath;
|
|
35
98
|
return null;
|
|
36
99
|
}
|
|
37
100
|
}
|
package/package.json
CHANGED
|
@@ -5,8 +5,9 @@
|
|
|
5
5
|
"url": "https://github.com/cezaraugusto/firefox-location2.git"
|
|
6
6
|
},
|
|
7
7
|
"name": "firefox-location2",
|
|
8
|
-
"version": "
|
|
8
|
+
"version": "2.0.0",
|
|
9
9
|
"description": "Approximates the current location of the Firefox browser across platforms.",
|
|
10
|
+
"homepage": "https://www.npmjs.com/package/firefox-location2",
|
|
10
11
|
"type": "module",
|
|
11
12
|
"exports": {
|
|
12
13
|
".": {
|
|
@@ -20,6 +21,26 @@
|
|
|
20
21
|
"files": [
|
|
21
22
|
"dist"
|
|
22
23
|
],
|
|
24
|
+
"bin": {
|
|
25
|
+
"firefox-location2": "bin.js"
|
|
26
|
+
},
|
|
27
|
+
"scripts": {
|
|
28
|
+
"build": "rslib build",
|
|
29
|
+
"check": "biome check --write",
|
|
30
|
+
"dev": "rslib build --watch",
|
|
31
|
+
"format": "biome format --write",
|
|
32
|
+
"test": "vitest run",
|
|
33
|
+
"prepublishOnly": "npm run build",
|
|
34
|
+
"publish:provenance": "np patch --no-tests --any-branch --yolo --message 'release: %s' --provenance"
|
|
35
|
+
},
|
|
36
|
+
"publishConfig": {
|
|
37
|
+
"provenance": true
|
|
38
|
+
},
|
|
39
|
+
"author": {
|
|
40
|
+
"name": "Cezar Augusto",
|
|
41
|
+
"email": "boss@cezaraugusto.net",
|
|
42
|
+
"url": "https://cezaraugusto.net"
|
|
43
|
+
},
|
|
23
44
|
"keywords": [
|
|
24
45
|
"firefox",
|
|
25
46
|
"browser",
|
|
@@ -40,11 +61,5 @@
|
|
|
40
61
|
"typescript": "^5.8.3",
|
|
41
62
|
"vitest": "^3.1.3"
|
|
42
63
|
},
|
|
43
|
-
"
|
|
44
|
-
|
|
45
|
-
"check": "biome check --write",
|
|
46
|
-
"dev": "rslib build --watch",
|
|
47
|
-
"format": "biome format --write",
|
|
48
|
-
"test": "vitest run"
|
|
49
|
-
}
|
|
50
|
-
}
|
|
64
|
+
"packageManager": "pnpm@9.9.0+sha512.60c18acd138bff695d339be6ad13f7e936eea6745660d4cc4a776d5247c540d0edee1a563695c183a66eb917ef88f2b4feb1fc25f32a7adcadc7aaf3438e99c1"
|
|
65
|
+
}
|