Skip to content

Commit

Permalink
Fix openBrowser() when BROWSER=open on macOS (#1690)
Browse files Browse the repository at this point in the history
* Fix openBrowser() when BROWSER=open on macOS

* Tweaks
  • Loading branch information
bpierre authored and gaearon committed Mar 5, 2017
1 parent 7daff97 commit 860f1c7
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/react-dev-utils/openBrowser.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function openBrowser(url) {
// Attempt to honor this environment variable.
// It is specific to the operating system.
// See https://github.com/sindresorhus/opn#app for documentation.
const browser = process.env.BROWSER;
let browser = process.env.BROWSER;

// Special case: BROWSER="none" will prevent opening completely.
if (browser === 'none') {
Expand Down Expand Up @@ -50,6 +50,14 @@ function openBrowser(url) {
}
}

// Another special case: on OS X, check if BROWSER has been set to "open".
// In this case, instead of passing `open` to `opn` (which won't work),
// just ignore it (thus ensuring the intended behavior, i.e. opening the system browser):
// https://github.com/facebookincubator/create-react-app/pull/1690#issuecomment-283518768
if (process.platform === 'darwin' && browser === 'open') {
browser = undefined;
}

// Fallback to opn
// (It will always open new tab)
try {
Expand Down

0 comments on commit 860f1c7

Please sign in to comment.