Skip to content

Commit

Permalink
Fix openBrowser() when BROWSER=open on macOS (facebook#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 randycoulman committed May 8, 2017
1 parent acd975f commit 6b713cc
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 6b713cc

Please sign in to comment.