Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow --open option to specify the browser to use #825

Merged
merged 18 commits into from
Aug 30, 2017
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions bin/webpack-dev-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ function processOptions(wpOpt) {
options.compress = true;

if(argv["open"])
options.open = true;
options.open = (argv["open"] === "") ? true : argv["open"];

// Kind of weird, but ensures prior behavior isn't broken in cases
// that wouldn't throw errors. E.g. both argv.port and options.port
Expand Down Expand Up @@ -418,7 +418,12 @@ function reportReadiness(uri, options) {
if(options.historyApiFallback)
console.log(`404s will fallback to ${colorInfo(useColor, options.historyApiFallback.index || "/index.html")}`);
if(options.open) {
open(uri).catch(function() {
var params = [uri];

if(typeof options.open === "string")
params.push({ app: options.open });

open(...params).catch(function() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Array spread doesn't seem to work in Node v4.

console.log("Unable to open browser. If you are running in a headless environment, please do not use the open flag.");
});
}
Expand Down
9 changes: 8 additions & 1 deletion lib/optionsSchema.json
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,14 @@
},
"open": {
"description": "Let the CLI open your browser with the URL.",
"type": "boolean"
"anyOf": [
{
"type": "string"
},
{
"type": "boolean"
}
]
},
"features": {
"description": "The order of which the features will be triggered.",
Expand Down