firefox-location2 1.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/LICENSE +21 -0
- package/README.md +45 -0
- package/dist/index.cjs +85 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +38 -0
- package/package.json +50 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Cezar Augusto
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
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]
|
|
9
|
+
|
|
10
|
+
> Approximates the current location of the Firefox browser across platforms.
|
|
11
|
+
|
|
12
|
+
# Usage
|
|
13
|
+
|
|
14
|
+
**Via Node.js:**
|
|
15
|
+
|
|
16
|
+
```js
|
|
17
|
+
// ESM
|
|
18
|
+
import firefoxLocation from 'firefox-location2'
|
|
19
|
+
|
|
20
|
+
// Returns the path to Firefox as a string
|
|
21
|
+
console.log(firefoxLocation())
|
|
22
|
+
// /Applications/Firefox.app/Contents/MacOS/firefox
|
|
23
|
+
|
|
24
|
+
// CommonJS
|
|
25
|
+
const firefoxLocation = require('firefox-location')
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Supported Platforms
|
|
29
|
+
|
|
30
|
+
- macOS (darwin)
|
|
31
|
+
- Windows (win32)
|
|
32
|
+
- Linux (default fallback)
|
|
33
|
+
|
|
34
|
+
## Related projects
|
|
35
|
+
|
|
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
|
+
* [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)
|
|
42
|
+
|
|
43
|
+
## License
|
|
44
|
+
|
|
45
|
+
MIT (c) Cezar Augusto.
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.n = (module)=>{
|
|
5
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
6
|
+
__webpack_require__.d(getter, {
|
|
7
|
+
a: getter
|
|
8
|
+
});
|
|
9
|
+
return getter;
|
|
10
|
+
};
|
|
11
|
+
})();
|
|
12
|
+
(()=>{
|
|
13
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
14
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: definition[key]
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
})();
|
|
20
|
+
(()=>{
|
|
21
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
22
|
+
})();
|
|
23
|
+
(()=>{
|
|
24
|
+
__webpack_require__.r = (exports1)=>{
|
|
25
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
26
|
+
value: 'Module'
|
|
27
|
+
});
|
|
28
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
29
|
+
value: true
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
})();
|
|
33
|
+
var __webpack_exports__ = {};
|
|
34
|
+
__webpack_require__.r(__webpack_exports__);
|
|
35
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
36
|
+
default: ()=>locateFirefox
|
|
37
|
+
});
|
|
38
|
+
const external_fs_namespaceObject = require("fs");
|
|
39
|
+
var external_fs_default = /*#__PURE__*/ __webpack_require__.n(external_fs_namespaceObject);
|
|
40
|
+
const external_path_namespaceObject = require("path");
|
|
41
|
+
var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject);
|
|
42
|
+
const external_os_namespaceObject = require("os");
|
|
43
|
+
var external_os_default = /*#__PURE__*/ __webpack_require__.n(external_os_namespaceObject);
|
|
44
|
+
const external_which_namespaceObject = require("which");
|
|
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 (_) {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
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;
|
|
59
|
+
}
|
|
60
|
+
{
|
|
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)']
|
|
66
|
+
];
|
|
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;
|
|
70
|
+
}
|
|
71
|
+
const defaultPaths = [
|
|
72
|
+
'C:\\Program Files\\Mozilla Firefox\\firefox.exe',
|
|
73
|
+
'C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe'
|
|
74
|
+
];
|
|
75
|
+
for (const defaultPath of defaultPaths)if (external_fs_default().existsSync(defaultPath)) return defaultPath;
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
exports["default"] = __webpack_exports__["default"];
|
|
80
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
81
|
+
"default"
|
|
82
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
83
|
+
Object.defineProperty(exports, '__esModule', {
|
|
84
|
+
value: true
|
|
85
|
+
});
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function locateFirefox(): string | null;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE_fs__ from "fs";
|
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE_path__ from "path";
|
|
3
|
+
import * as __WEBPACK_EXTERNAL_MODULE_os__ from "os";
|
|
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 (_) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
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;
|
|
18
|
+
}
|
|
19
|
+
{
|
|
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)']
|
|
25
|
+
];
|
|
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;
|
|
29
|
+
}
|
|
30
|
+
const defaultPaths = [
|
|
31
|
+
'C:\\Program Files\\Mozilla Firefox\\firefox.exe',
|
|
32
|
+
'C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe'
|
|
33
|
+
];
|
|
34
|
+
for (const defaultPath of defaultPaths)if (__WEBPACK_EXTERNAL_MODULE_fs__["default"].existsSync(defaultPath)) return defaultPath;
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export { locateFirefox as default };
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"license": "MIT",
|
|
3
|
+
"repository": {
|
|
4
|
+
"type": "git",
|
|
5
|
+
"url": "https://github.com/cezaraugusto/firefox-location2.git"
|
|
6
|
+
},
|
|
7
|
+
"name": "firefox-location2",
|
|
8
|
+
"version": "1.0.0",
|
|
9
|
+
"description": "Approximates the current location of the Firefox browser across platforms.",
|
|
10
|
+
"type": "module",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"import": "./dist/index.js",
|
|
15
|
+
"require": "./dist/index.cjs"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"main": "./dist/index.cjs",
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"files": [
|
|
21
|
+
"dist"
|
|
22
|
+
],
|
|
23
|
+
"keywords": [
|
|
24
|
+
"firefox",
|
|
25
|
+
"browser",
|
|
26
|
+
"spawn",
|
|
27
|
+
"location",
|
|
28
|
+
"process",
|
|
29
|
+
"guesstimate"
|
|
30
|
+
],
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"userhome": "^1.0.0",
|
|
33
|
+
"which": "^2.0.2"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@biomejs/biome": "^1.9.4",
|
|
37
|
+
"@rslib/core": "^0.6.9",
|
|
38
|
+
"@types/node": "^22.8.1",
|
|
39
|
+
"@types/which": "^3.0.4",
|
|
40
|
+
"typescript": "^5.8.3",
|
|
41
|
+
"vitest": "^3.1.3"
|
|
42
|
+
},
|
|
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
|
+
}
|