Q:

How does create-react-app re-use an existing Browser tab after running `npm run start`?

Running open http://localhost:8080 in Terminal will open a new tab each time.
How does create-react-app re-use an existing Browser tab, when available?
Update
It looks like here is the place where the magic happens:
function startBrowserProcess(browser, url) {
  // If we're on OS X, the user hasn't specifically
  // requested a different browser, we can try opening
  // Chrome with AppleScript. This lets us reuse an
  // existing tab when possible instead of creating a new one.
  const shouldTryOpenChromeWithAppleScript =
    process.platform === 'darwin' &&
    (typeof browser !== 'string' || browser === OSX_CHROME);

  if (shouldTryOpenChromeWithAppleScript) {
    try {
      // Try our best to reuse existing tab
      // on OS X Google Chrome with AppleScript
      execSync('ps cax | grep "Google Chrome"');
      execSync('osascript openChrome.applescript "' + encodeURI(url) + '"', {
        cwd: __dirname,
        stdio: 'ignore',
      });
      return true;
    } catch (err) {
      // Ignore errors.
    }
  }

  // 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/facebook/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 {
    var options = { app: browser };
    opn(url, options).catch(() => {}); // Prevent `unhandledRejection` error.
    return true;
  } catch (err) {
    return false;
  }
}

However, I still don't know how this is working.  I am on OS X, and I do have the osascript binary, surprisingly. But I'm not sure how to use it within Terminal.
I've tried osascript openChrome.applescript "localhost:8080", but I'm getting the following error:
osascript: openChrome.applescript: No such file or directory
What is the proper use of the osascript command to open http://localhost:8080 in the current tab, if it exists?
Update
It looks like the openChrome.applescript file is somewhere included within create-react-app, but I'm not sure where.

A:

I just tested osascript /path/to/openChrome.applescript "http://localhost:8080" and it works as expected.
If you don't have the openChrome.applescript script, then here its source code URL: openChrome.applescript

