safari-location2
v2.0.0
Published
Approximates the current location of the Safari browser across platforms.
Maintainers
Readme
Approximates the current location of the Safari browser across platforms.
safari-location2

- By default checks only
stable. Optionally can cascade toTechnology Preview. - Supports macOS
- Works both as an ES module or CommonJS
Support table
This table lists the default locations where Safari 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.
Returns the first existing path found (given selected channels), or null if none are found.
Usage
Via Node.js (strict by default):
import safariLocation from "safari-location2";
import {
locateSafariOrExplain,
getInstallGuidance,
getSafariVersion
} from "safari-location2";
// Strict (Stable only)
console.log(safariLocation());
// => "/Applications/Safari.app/Contents/MacOS/Safari" or null
// Enable fallback (Stable / Technology Preview)
console.log(safariLocation(true));
// => first found among Stable/Technology Preview or null
// Throw with a friendly guide when not found
try {
const bin = locateSafariOrExplain({allowFallback: true});
console.log(bin);
// Version (no exec by default)
console.log(getSafariVersion(bin)); // e.g. "17.6" or null
} catch (e) {
console.error(String(e));
// Or print getInstallGuidance() explicitly
}Via CLI:
npx safari-location2
# Strict (Stable only)
npx safari-location2 --fallback
# Enable cascade (Stable / Technology Preview)
# Respect environment overrides
SAFARI_BINARY=/custom/path/to/Safari npx safari-location2
# Print browser version (empty + exit code 2 if unavailable)
npx safari-location2 --safari-version
npx safari-location2 --browser-version
# Opt-in: allow executing the binary to fetch version
npx safari-location2 --browser-version --allow-execEnvironment overrides
If this environment variable is set and points to an existing binary, it takes precedence:
SAFARI_BINARY
API
default export locateSafari(allowFallback?: boolean): string | nulllocateSafariOrExplain(options?: boolean | { allowFallback?: boolean }): stringgetSafariVersion(bin: string, opts?: { allowExec?: boolean }): string | nullgetInstallGuidance(): string
Related projects
- brave-location
- chrome-location2
- edge-location
- firefox-location2
- opera-location2
- vivaldi-location2
- yandex-location
- librewolf-location
- waterfox-location
License
MIT (c) Cezar Augusto.
