Created
April 27, 2021 05:23
-
-
Save benjaminfauchald/97a55fe5c70e2c6d4f5ecf0057ae058a to your computer and use it in GitHub Desktop.
Cross platform check with JS shell exec
This file contains 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
const exec = require('child_process').exec; | |
function openURL(url) { | |
let opener; | |
switch (process.platform) { | |
case 'darwin': | |
opener = 'open'; | |
break; | |
case 'win32': | |
opener = 'start'; | |
break; | |
default: | |
opener = 'xdg-open'; | |
break; | |
} | |
return exec(`${opener} "${url.replace(/"/g, '\\\"')}"`); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment