Use opn to open the default browser in a cross-platform way (#4)

This commit is contained in:
Jonny Buchanan
2016-07-17 21:01:56 +01:00
committed by Christopher Chedeau
parent 4fe3544f5b
commit a00e1e6dd3
2 changed files with 3 additions and 6 deletions

View File

@@ -13,6 +13,7 @@ var webpack = require('webpack');
var WebpackDevServer = require('webpack-dev-server');
var config = require('../webpack.config.dev');
var execSync = require('child_process').execSync;
var opn = require('opn');
new WebpackDevServer(webpack(config), {
publicPath: config.output.publicPath,
@@ -39,10 +40,5 @@ new WebpackDevServer(webpack(config), {
}
console.log('Listening at http://localhost:3000/');
try {
execSync('ps cax | grep "Google Chrome"');
execSync('open -a "Google Chrome" http://localhost:3000/');
} catch(e) {
// Do nothing if Chrome isn't opened or cannot be opened
}
opn('http://localhost:3000/');
});