firefox-location2 1.0.0 → 2.0.1

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 CHANGED
@@ -1,44 +1,203 @@
1
- [npm-image]: https://img.shields.io/npm/v/firefox-location2.svg
2
- [npm-url]: https://npmjs.org/package/firefox-location2
3
- [action-image]: https://github.com/cezaraugusto/firefox-location2/workflows/CI/badge.svg
4
- [action-url]: https://github.com/cezaraugusto/firefox-location2/actions?query=workflow%3ACI
5
- [downloads-image]: https://img.shields.io/npm/dm/firefox-location2.svg
6
- [downloads-url]: https://npmjs.org/package/firefox-location2
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
- # Usage
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
+ * By default checks only `stable`. Optionally can cascade to `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. By default, only the Stable channel is checked. When fallback is enabled, 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 (given selected channels), 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>.
13
159
 
14
- **Via Node.js:**
160
+ ## Usage
161
+
162
+ **Via Node.js (strict by default):**
15
163
 
16
164
  ```js
17
- // ESM
18
- import firefoxLocation from 'firefox-location2'
165
+ import firefoxLocation from "firefox-location2";
19
166
 
20
- // Returns the path to Firefox as a string
21
- console.log(firefoxLocation())
22
- // /Applications/Firefox.app/Contents/MacOS/firefox
167
+ // Strict (Stable only)
168
+ console.log(firefoxLocation());
169
+ // => "/Applications/Firefox.app/Contents/MacOS/firefox" or null
23
170
 
24
- // CommonJS
25
- const firefoxLocation = require('firefox-location')
171
+ // Enable fallback (Stable / ESR / Developer Edition / Nightly)
172
+ console.log(firefoxLocation(true));
173
+ // => first found among Stable/ESR/Developer/Nightly or null
26
174
  ```
27
175
 
28
- ## Supported Platforms
176
+ **Via CLI:**
177
+
178
+ ```bash
179
+ npx firefox-location2
180
+ # Strict (Stable only)
181
+
182
+ npx firefox-location2 --fallback
183
+ # Enable cascade (Stable / ESR / Developer / Nightly)
184
+ ```
29
185
 
30
- - macOS (darwin)
31
- - Windows (win32)
32
- - Linux (default fallback)
186
+ ## Planned enhancements
187
+
188
+ - Flatpak detection on Linux: detect installed Flatpak app <code>org.mozilla.firefox</code> and expose the appropriate invocation.
189
+ - 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>.
190
+ - Optional binary validation: helper to return <code>firefox --version</code> (or Flatpak equivalent) for diagnostics.
191
+ - 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
192
 
34
193
  ## Related projects
35
194
 
36
- * [chrome-location2](https://github.com/hughsk/chrome-location2)
37
- * [edge-location](https://github.com/cezaraugusto/edge-location)
38
- * [firefox-location](https://github.com/hughsk/firefox-location)
39
195
  * [brave-location](https://github.com/cezaraugusto/brave-location)
40
- * [vivaldi-location](https://github.com/jandrey/vivaldi-location)
41
- * [opera-location](https://github.com/jandrey/opera-location)
196
+ * [chrome-location2](https://github.com/cezaraugusto/chrome-location2)
197
+ * [edge-location](https://github.com/cezaraugusto/edge-location)
198
+ * [opera-location2](https://github.com/cezaraugusto/opera-location2)
199
+ * [vivaldi-location2](https://github.com/cezaraugusto/vivaldi-location2)
200
+ * [yandex-location2](https://github.com/cezaraugusto/yandex-location2)
42
201
 
43
202
  ## License
44
203
 
package/bin.js ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env node
2
+
3
+ const locateFirefox =
4
+ require('./dist/index.cjs').default || require('./dist/index.cjs');
5
+
6
+ const argv = process.argv.slice(2);
7
+ const allowFallback = argv.includes('--fallback') || argv.includes('-f');
8
+
9
+ console.log(locateFirefox(allowFallback));
package/dist/index.cjs CHANGED
@@ -43,36 +43,117 @@ 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
- const osx = 'darwin' === process.platform;
47
- const win = 'win32' === process.platform;
48
- const other = !osx && !win;
49
- function locateFirefox() {
50
- if (other) try {
51
- return external_which_default().sync('firefox');
52
- } catch (_) {
46
+ function locateFirefox(allowFallbackOrDeps, depsMaybe) {
47
+ const isBoolean = 'boolean' == typeof allowFallbackOrDeps;
48
+ const allowFallback = isBoolean ? allowFallbackOrDeps : false;
49
+ const deps = isBoolean ? depsMaybe : allowFallbackOrDeps;
50
+ const f = (null == deps ? void 0 : deps.fs) ?? external_fs_default();
51
+ const w = (null == deps ? void 0 : deps.which) ?? external_which_default();
52
+ const o = (null == deps ? void 0 : deps.os) ?? external_os_default();
53
+ const p = (null == deps ? void 0 : deps.path) ?? external_path_default();
54
+ const env = (null == deps ? void 0 : deps.env) ?? process.env;
55
+ const platform = (null == deps ? void 0 : deps.platform) ?? process.platform;
56
+ const osx = 'darwin' === platform;
57
+ const win = 'win32' === platform;
58
+ const other = !osx && !win;
59
+ if (other) {
60
+ const stable = [
61
+ 'firefox'
62
+ ];
63
+ const fallbacks = [
64
+ 'firefox-esr',
65
+ 'firefox-developer-edition',
66
+ 'firefox-devedition',
67
+ 'firefox-nightly'
68
+ ];
69
+ const candidates = allowFallback ? [
70
+ ...stable,
71
+ ...fallbacks
72
+ ] : stable;
73
+ for (const cmd of candidates)try {
74
+ const resolved = w.sync(cmd);
75
+ if (resolved) return resolved;
76
+ } catch (_) {}
77
+ if (allowFallback) {
78
+ const linuxPaths = [
79
+ '/usr/bin/firefox',
80
+ '/usr/local/bin/firefox',
81
+ '/usr/lib/firefox/firefox',
82
+ '/snap/bin/firefox',
83
+ '/opt/firefox/firefox',
84
+ '/usr/local/firefox/firefox',
85
+ p.join(o.homedir(), 'bin', 'firefox'),
86
+ p.join(o.homedir(), 'Downloads', 'firefox', 'firefox'),
87
+ p.join(o.homedir(), '.local', 'share', 'flatpak', 'exports', 'bin', 'org.mozilla.firefox'),
88
+ '/var/lib/flatpak/exports/bin/org.mozilla.firefox'
89
+ ];
90
+ for (const linuxPath of linuxPaths)if (f.existsSync(linuxPath)) return linuxPath;
91
+ }
53
92
  return null;
54
93
  }
55
94
  if (osx) {
56
- const regPath = '/Applications/Firefox.app/Contents/MacOS/firefox';
57
- const altPath = external_path_default().join(external_os_default().homedir(), regPath.slice(1));
58
- return external_fs_default().existsSync(regPath) ? regPath : external_fs_default().existsSync(altPath) ? altPath : null;
95
+ const appsAll = [
96
+ {
97
+ app: 'Firefox.app',
98
+ exec: 'firefox'
99
+ },
100
+ {
101
+ app: 'Firefox ESR.app',
102
+ exec: 'firefox'
103
+ },
104
+ {
105
+ app: 'Firefox Developer Edition.app',
106
+ exec: 'firefox'
107
+ },
108
+ {
109
+ app: 'Firefox Nightly.app',
110
+ exec: 'firefox'
111
+ }
112
+ ];
113
+ const apps = allowFallback ? appsAll : [
114
+ appsAll[0]
115
+ ];
116
+ const systemBase = '/Applications';
117
+ const userBase = p.join(o.homedir(), 'Applications');
118
+ for (const { app, exec } of apps){
119
+ const systemPath = `${systemBase}/${app}/Contents/MacOS/${exec}`;
120
+ if (f.existsSync(systemPath)) return systemPath;
121
+ const userPath = `${userBase}/${app}/Contents/MacOS/${exec}`;
122
+ if (f.existsSync(userPath)) return userPath;
123
+ }
124
+ return null;
59
125
  }
60
126
  {
61
- const suffix = external_path_default().join('Mozilla Firefox', 'firefox.exe');
62
- const possiblePaths = [
63
- process.env.LOCALAPPDATA,
64
- process.env.PROGRAMFILES,
65
- process.env['PROGRAMFILES(X86)']
127
+ const prefixes = [
128
+ env.LOCALAPPDATA,
129
+ env.PROGRAMFILES,
130
+ env['PROGRAMFILES(X86)']
131
+ ].filter(Boolean);
132
+ const suffixesAll = [
133
+ p.join('Mozilla Firefox', 'firefox.exe'),
134
+ p.join('Mozilla Firefox ESR', 'firefox.exe'),
135
+ p.join('Mozilla Firefox Developer Edition', 'firefox.exe'),
136
+ p.join('Firefox Nightly', 'firefox.exe')
137
+ ];
138
+ const suffixes = allowFallback ? suffixesAll : [
139
+ suffixesAll[0]
66
140
  ];
67
- for (const prefix of possiblePaths)if (prefix) {
68
- const exePath = external_path_default().join(prefix, suffix);
69
- if (external_fs_default().existsSync(exePath)) return exePath;
141
+ for (const prefix of prefixes)for (const suffix of suffixes){
142
+ const exePath = p.join(prefix, suffix);
143
+ if (f.existsSync(exePath)) return exePath;
70
144
  }
71
- const defaultPaths = [
145
+ const defaultPathsAll = [
72
146
  'C:\\Program Files\\Mozilla Firefox\\firefox.exe',
73
- 'C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe'
147
+ 'C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe',
148
+ 'C:\\Program Files\\Mozilla Firefox ESR\\firefox.exe',
149
+ 'C:\\Program Files (x86)\\Mozilla Firefox ESR\\firefox.exe',
150
+ 'C:\\Program Files\\Mozilla Firefox Developer Edition\\firefox.exe',
151
+ 'C:\\Program Files (x86)\\Mozilla Firefox Developer Edition\\firefox.exe',
152
+ 'C:\\Program Files\\Firefox Nightly\\firefox.exe',
153
+ 'C:\\Program Files (x86)\\Firefox Nightly\\firefox.exe'
74
154
  ];
75
- for (const defaultPath of defaultPaths)if (external_fs_default().existsSync(defaultPath)) return defaultPath;
155
+ const defaultPaths = allowFallback ? defaultPathsAll : defaultPathsAll.slice(0, 2);
156
+ for (const defaultPath of defaultPaths)if (f.existsSync(defaultPath)) return defaultPath;
76
157
  return null;
77
158
  }
78
159
  }
package/dist/index.d.ts CHANGED
@@ -1 +1,19 @@
1
- export default function locateFirefox(): string | null;
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(allowFallbackOrDeps?: boolean | Deps, depsMaybe?: Deps): string | null;
package/dist/index.js CHANGED
@@ -2,36 +2,117 @@ 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
- const osx = 'darwin' === process.platform;
6
- const win = 'win32' === process.platform;
7
- const other = !osx && !win;
8
- function locateFirefox() {
9
- if (other) try {
10
- return __WEBPACK_EXTERNAL_MODULE_which__["default"].sync('firefox');
11
- } catch (_) {
5
+ function locateFirefox(allowFallbackOrDeps, depsMaybe) {
6
+ const isBoolean = 'boolean' == typeof allowFallbackOrDeps;
7
+ const allowFallback = isBoolean ? allowFallbackOrDeps : false;
8
+ const deps = isBoolean ? depsMaybe : allowFallbackOrDeps;
9
+ const f = (null == deps ? void 0 : deps.fs) ?? __WEBPACK_EXTERNAL_MODULE_fs__["default"];
10
+ const w = (null == deps ? void 0 : deps.which) ?? __WEBPACK_EXTERNAL_MODULE_which__["default"];
11
+ const o = (null == deps ? void 0 : deps.os) ?? __WEBPACK_EXTERNAL_MODULE_os__["default"];
12
+ const p = (null == deps ? void 0 : deps.path) ?? __WEBPACK_EXTERNAL_MODULE_path__["default"];
13
+ const env = (null == deps ? void 0 : deps.env) ?? process.env;
14
+ const platform = (null == deps ? void 0 : deps.platform) ?? process.platform;
15
+ const osx = 'darwin' === platform;
16
+ const win = 'win32' === platform;
17
+ const other = !osx && !win;
18
+ if (other) {
19
+ const stable = [
20
+ 'firefox'
21
+ ];
22
+ const fallbacks = [
23
+ 'firefox-esr',
24
+ 'firefox-developer-edition',
25
+ 'firefox-devedition',
26
+ 'firefox-nightly'
27
+ ];
28
+ const candidates = allowFallback ? [
29
+ ...stable,
30
+ ...fallbacks
31
+ ] : stable;
32
+ for (const cmd of candidates)try {
33
+ const resolved = w.sync(cmd);
34
+ if (resolved) return resolved;
35
+ } catch (_) {}
36
+ if (allowFallback) {
37
+ const linuxPaths = [
38
+ '/usr/bin/firefox',
39
+ '/usr/local/bin/firefox',
40
+ '/usr/lib/firefox/firefox',
41
+ '/snap/bin/firefox',
42
+ '/opt/firefox/firefox',
43
+ '/usr/local/firefox/firefox',
44
+ p.join(o.homedir(), 'bin', 'firefox'),
45
+ p.join(o.homedir(), 'Downloads', 'firefox', 'firefox'),
46
+ p.join(o.homedir(), '.local', 'share', 'flatpak', 'exports', 'bin', 'org.mozilla.firefox'),
47
+ '/var/lib/flatpak/exports/bin/org.mozilla.firefox'
48
+ ];
49
+ for (const linuxPath of linuxPaths)if (f.existsSync(linuxPath)) return linuxPath;
50
+ }
12
51
  return null;
13
52
  }
14
53
  if (osx) {
15
- const regPath = '/Applications/Firefox.app/Contents/MacOS/firefox';
16
- const altPath = __WEBPACK_EXTERNAL_MODULE_path__["default"].join(__WEBPACK_EXTERNAL_MODULE_os__["default"].homedir(), regPath.slice(1));
17
- return __WEBPACK_EXTERNAL_MODULE_fs__["default"].existsSync(regPath) ? regPath : __WEBPACK_EXTERNAL_MODULE_fs__["default"].existsSync(altPath) ? altPath : null;
54
+ const appsAll = [
55
+ {
56
+ app: 'Firefox.app',
57
+ exec: 'firefox'
58
+ },
59
+ {
60
+ app: 'Firefox ESR.app',
61
+ exec: 'firefox'
62
+ },
63
+ {
64
+ app: 'Firefox Developer Edition.app',
65
+ exec: 'firefox'
66
+ },
67
+ {
68
+ app: 'Firefox Nightly.app',
69
+ exec: 'firefox'
70
+ }
71
+ ];
72
+ const apps = allowFallback ? appsAll : [
73
+ appsAll[0]
74
+ ];
75
+ const systemBase = '/Applications';
76
+ const userBase = p.join(o.homedir(), 'Applications');
77
+ for (const { app, exec } of apps){
78
+ const systemPath = `${systemBase}/${app}/Contents/MacOS/${exec}`;
79
+ if (f.existsSync(systemPath)) return systemPath;
80
+ const userPath = `${userBase}/${app}/Contents/MacOS/${exec}`;
81
+ if (f.existsSync(userPath)) return userPath;
82
+ }
83
+ return null;
18
84
  }
19
85
  {
20
- const suffix = __WEBPACK_EXTERNAL_MODULE_path__["default"].join('Mozilla Firefox', 'firefox.exe');
21
- const possiblePaths = [
22
- process.env.LOCALAPPDATA,
23
- process.env.PROGRAMFILES,
24
- process.env['PROGRAMFILES(X86)']
86
+ const prefixes = [
87
+ env.LOCALAPPDATA,
88
+ env.PROGRAMFILES,
89
+ env['PROGRAMFILES(X86)']
90
+ ].filter(Boolean);
91
+ const suffixesAll = [
92
+ p.join('Mozilla Firefox', 'firefox.exe'),
93
+ p.join('Mozilla Firefox ESR', 'firefox.exe'),
94
+ p.join('Mozilla Firefox Developer Edition', 'firefox.exe'),
95
+ p.join('Firefox Nightly', 'firefox.exe')
96
+ ];
97
+ const suffixes = allowFallback ? suffixesAll : [
98
+ suffixesAll[0]
25
99
  ];
26
- for (const prefix of possiblePaths)if (prefix) {
27
- const exePath = __WEBPACK_EXTERNAL_MODULE_path__["default"].join(prefix, suffix);
28
- if (__WEBPACK_EXTERNAL_MODULE_fs__["default"].existsSync(exePath)) return exePath;
100
+ for (const prefix of prefixes)for (const suffix of suffixes){
101
+ const exePath = p.join(prefix, suffix);
102
+ if (f.existsSync(exePath)) return exePath;
29
103
  }
30
- const defaultPaths = [
104
+ const defaultPathsAll = [
31
105
  'C:\\Program Files\\Mozilla Firefox\\firefox.exe',
32
- 'C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe'
106
+ 'C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe',
107
+ 'C:\\Program Files\\Mozilla Firefox ESR\\firefox.exe',
108
+ 'C:\\Program Files (x86)\\Mozilla Firefox ESR\\firefox.exe',
109
+ 'C:\\Program Files\\Mozilla Firefox Developer Edition\\firefox.exe',
110
+ 'C:\\Program Files (x86)\\Mozilla Firefox Developer Edition\\firefox.exe',
111
+ 'C:\\Program Files\\Firefox Nightly\\firefox.exe',
112
+ 'C:\\Program Files (x86)\\Firefox Nightly\\firefox.exe'
33
113
  ];
34
- for (const defaultPath of defaultPaths)if (__WEBPACK_EXTERNAL_MODULE_fs__["default"].existsSync(defaultPath)) return defaultPath;
114
+ const defaultPaths = allowFallback ? defaultPathsAll : defaultPathsAll.slice(0, 2);
115
+ for (const defaultPath of defaultPaths)if (f.existsSync(defaultPath)) return defaultPath;
35
116
  return null;
36
117
  }
37
118
  }
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": "1.0.0",
8
+ "version": "2.0.1",
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
- "scripts": {
44
- "build": "rslib build",
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
+ }