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

feat(cli): add option to specify the browser to open #117

Merged
merged 4 commits into from
Nov 22, 2016
Merged
Show file tree
Hide file tree
Changes from all 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: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,15 @@ You can also specify an HTML file, which `quik` will parse for any local scripts
```sh
quik --html index.html --output output.html
```
## Specify browser to open

You can specify which browser to open when server starts. Refer [opn](https://npmjs.com/opn)'s documentation on browser names.

For example, to use firefox as the browser, you'd do,

```sh
quik --browser firefox
```

## Sample project

Expand Down
12 changes: 11 additions & 1 deletion src/quik-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ const argv = yargs
default: true,
description: 'Generate sourcemaps for bundle',
},
browser: {
type: 'string',
default: '',
description: 'Name of using browser',
},
})
.example('$0 --run index.js', 'Run the script \'index.js\' in a browser and watch for changes')
.example('$0 --port 8008 --watch index.js', 'Start the server in the port \'8008\' and watch \'index.js\' for changes')
Expand Down Expand Up @@ -131,5 +136,10 @@ if (argv.init) {
const url = `http://localhost:${argv.port}`;

console.log(`Quik is serving files at ${chalk.blue(url)}`);
opn(url);

if (argv.browser) {
opn(url, {app: argv.browser});
} else {
opn(url);
}
}