Skip to content

Commit 6b713cc

Browse files
bpierrerandycoulman
authored andcommitted
Fix openBrowser() when BROWSER=open on macOS (facebook#1690)
* Fix openBrowser() when BROWSER=open on macOS * Tweaks
1 parent acd975f commit 6b713cc

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

packages/react-dev-utils/openBrowser.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function openBrowser(url) {
1717
// Attempt to honor this environment variable.
1818
// It is specific to the operating system.
1919
// See https://github.com/sindresorhus/opn#app for documentation.
20-
const browser = process.env.BROWSER;
20+
let browser = process.env.BROWSER;
2121

2222
// Special case: BROWSER="none" will prevent opening completely.
2323
if (browser === 'none') {
@@ -50,6 +50,14 @@ function openBrowser(url) {
5050
}
5151
}
5252

53+
// Another special case: on OS X, check if BROWSER has been set to "open".
54+
// In this case, instead of passing `open` to `opn` (which won't work),
55+
// just ignore it (thus ensuring the intended behavior, i.e. opening the system browser):
56+
// https://github.com/facebookincubator/create-react-app/pull/1690#issuecomment-283518768
57+
if (process.platform === 'darwin' && browser === 'open') {
58+
browser = undefined;
59+
}
60+
5361
// Fallback to opn
5462
// (It will always open new tab)
5563
try {

0 commit comments

Comments
 (0)