Skip to content

Commit 4ca8bf9

Browse files
Kazushige Tominagasatya164
authored andcommitted
feat(cli): add option to specify the browser to open (#117)
1 parent d2fbc70 commit 4ca8bf9

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,15 @@ You can also specify an HTML file, which `quik` will parse for any local scripts
115115
```sh
116116
quik --html index.html --output output.html
117117
```
118+
## Specify browser to open
119+
120+
You can specify which browser to open when server starts. Refer [opn](https://npmjs.com/opn)'s documentation on browser names.
121+
122+
For example, to use firefox as the browser, you'd do,
123+
124+
```sh
125+
quik --browser firefox
126+
```
118127

119128
## Sample project
120129

src/quik-cli.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ const argv = yargs
5454
default: true,
5555
description: 'Generate sourcemaps for bundle',
5656
},
57+
browser: {
58+
type: 'string',
59+
default: '',
60+
description: 'Name of using browser',
61+
},
5762
})
5863
.example('$0 --run index.js', 'Run the script \'index.js\' in a browser and watch for changes')
5964
.example('$0 --port 8008 --watch index.js', 'Start the server in the port \'8008\' and watch \'index.js\' for changes')
@@ -131,5 +136,10 @@ if (argv.init) {
131136
const url = `http://localhost:${argv.port}`;
132137

133138
console.log(`Quik is serving files at ${chalk.blue(url)}`);
134-
opn(url);
139+
140+
if (argv.browser) {
141+
opn(url, {app: argv.browser});
142+
} else {
143+
opn(url);
144+
}
135145
}

0 commit comments

Comments
 (0)