Skip to content

Commit

Permalink
Use opn to open the default browser in a cross-platform way (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
insin authored and vjeux committed Jul 17, 2016
1 parent e2f4942 commit 1b1c82f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"file-loader": "^0.9.0",
"html-webpack-plugin": "^2.22.0",
"json-loader": "^0.5.4",
"opn": "^4.0.2",
"postcss-loader": "^0.9.1",
"rimraf": "^2.5.3",
"style-loader": "^0.13.1",
Expand Down
8 changes: 2 additions & 6 deletions scripts/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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/');
});

0 comments on commit 1b1c82f

Please sign in to comment.