mirror of
https://github.com/zhigang1992/create-react-app.git
synced 2026-04-24 05:05:53 +08:00
Use opn to open the default browser in a cross-platform way (#4)
This commit is contained in:
committed by
Christopher Chedeau
parent
4fe3544f5b
commit
a00e1e6dd3
@@ -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/');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user