Skip to content

Instantly share code, notes, and snippets.

@eisisig
Created September 15, 2016 09:38
Show Gist options
  • Save eisisig/cc6cb1c3b13094f4ea2dc2ab7c9c936a to your computer and use it in GitHub Desktop.
Save eisisig/cc6cb1c3b13094f4ea2dc2ab7c9c936a to your computer and use it in GitHub Desktop.
Try to open previous browser tab in mac chrome
if (process.platform === 'darwin') {
try {
// Try our best to reuse existing tab
// on OS X Google Chrome with AppleScript
execSync('ps cax | grep "Google Chrome"');
execSync(
'osascript chrome.applescript ' + protocol + '://localhost:' + port + '/',
{cwd: path.join(__dirname, 'utils'), stdio: 'ignore'}
);
return;
} catch (err) {
// Ignore errors.
}
}
// Fallback to opn
// (It will always open new tab)
opn(protocol + '://localhost:' + port + '/');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment