better-opn icon indicating copy to clipboard operation
better-opn copied to clipboard

Should respect OS user preferences rather than default to a "better" browser

Open Chudesnov opened this issue 1 year ago • 0 comments

Since this package is widely used (by Storybook, Gatsby, and others) and it's not easy to find docs on how it is supposed to be configured (via the BROWSER environment variable, I believe), I would suggest that this package checks user OS preferences first before defaulting to something like:

  const shouldTryOpenChromiumWithAppleScript =
    process.platform === 'darwin' &&
    (typeof browser !== 'string' || browser === OSX_CHROME);

(https://github.com/michaellzc/better-opn/blob/master/src/index.js#L53)

(For me personally, it was non-straightforward that Gatsby always opened my dev build in Chrome even though it's not my default browser, even if that allowed some advanced behaviour like re-using the same tab).

We can detect the default browser through a package like x-default-browser, and if it is indeed one of the supported Chromium browsers, then it should, of course utilise its advanced capabilities.

Any thoughts on that? Happy to send in a PR to add OS preferences checking and do the necessary work to ensure backward compatibility if you're okay with this change.

Chudesnov avatar Aug 23 '22 12:08 Chudesnov