Skip to content

Commit a00e1e6

Browse files
insinvjeux
authored andcommitted
Use opn to open the default browser in a cross-platform way (#4)
1 parent 4fe3544 commit a00e1e6

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
"file-loader": "^0.9.0",
4242
"html-webpack-plugin": "^2.22.0",
4343
"json-loader": "^0.5.4",
44+
"opn": "^4.0.2",
4445
"postcss-loader": "^0.9.1",
4546
"rimraf": "^2.5.3",
4647
"style-loader": "^0.13.1",

scripts/start.js

+2-6
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ var webpack = require('webpack');
1313
var WebpackDevServer = require('webpack-dev-server');
1414
var config = require('../webpack.config.dev');
1515
var execSync = require('child_process').execSync;
16+
var opn = require('opn');
1617

1718
new WebpackDevServer(webpack(config), {
1819
publicPath: config.output.publicPath,
@@ -39,10 +40,5 @@ new WebpackDevServer(webpack(config), {
3940
}
4041
console.log('Listening at http://localhost:3000/');
4142

42-
try {
43-
execSync('ps cax | grep "Google Chrome"');
44-
execSync('open -a "Google Chrome" http://localhost:3000/');
45-
} catch(e) {
46-
// Do nothing if Chrome isn't opened or cannot be opened
47-
}
43+
opn('http://localhost:3000/');
4844
});

0 commit comments

Comments
 (0)