Skip to content

Commit

Permalink
feat(cli): add option to specify the browser to open (#117)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kazushige Tominaga authored and satya164 committed Nov 22, 2016
1 parent d2fbc70 commit 4ca8bf9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
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);
}
}

0 comments on commit 4ca8bf9

Please sign in to comment.