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 SpaceK33z committed Mar 7, 2017
1 parent 10e0ec4 commit 357941a
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/react-cy-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 357941a

Please sign in to comment.