Created
September 15, 2016 09:38
-
-
Save eisisig/cc6cb1c3b13094f4ea2dc2ab7c9c936a to your computer and use it in GitHub Desktop.
Try to open previous browser tab in mac chrome
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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