Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • C create-react-app
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1,547
    • Issues 1,547
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 417
    • Merge requests 417
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Meta
  • create-react-app
  • Merge requests
  • !2869

Prefer the default browser in openBrowser 馃敟馃

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Administrator requested to merge github/fork/clarkbw/default-browser into master Jul 28, 2017
  • Overview 9
  • Commits 3
  • Pipelines 0
  • Changes 3

Created by: clarkbw

This fixes #1826 (closed)

The problem is that if Chrome is currently running it doesn't matter that you have another browser set as your default, Chrome will be used.

I only noticed this recently as I haven't been running Chrome as much anymore and the script started opening Firefox by default. 馃帀 馃敟馃

Testing

To test, use the following test script (from the README).

// openBrowser.test.js
var openBrowser = require('./openBrowser');

if (openBrowser('http://localhost:3000')) {
  console.log('The browser tab has been opened!');
}

node openBrowser.test.js

Before this change:

  • With Chrome running this would open up Chrome even if it is not the default browser
  • Chrome reuses the same tab on OS X, a nice feature!

After this change:

  • With Chrome running, but not set as the default, this opens the default (Firefox, Safari, Chrome Canary, or other)
  • With Chrome set as the default browser the tab reuse feature continues to work as before

Notes

  • I added wait: false to the options because it was causing the script to hang waiting on the browser process to exit, which is unlikely. Here are the option notes from opn

Wait for the opened app to exit before fulfilling the promise. If false it's fulfilled immediately when opening the app.

  • I updated the README section slightly to remove an unneeded import
Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/clarkbw/default-browser