feat(v2): add ability disable to open page in browser when start command (#1856)

* feat(v2): add ability disable to open page in browser when start command

* Replace disable-open-browser with no-open

* Fixes
This commit is contained in:
Alexey Pyltsyn 2019-10-19 07:17:34 +03:00 committed by Endi
parent 9eb05d8711
commit e408d72d26
5 changed files with 7 additions and 2 deletions

View file

@ -7,6 +7,7 @@
- Add `extendCli` api for plugins. This will allow plugin to further extend Docusaurus CLI.
- Fix `swizzle` command not being able to swizzle single js file.
- Fix logo URL in footer to be appended with baseUrl automatically.
- Add the option `--no-open` for `start` command.
## 2.0.0-alpha.27

View file

@ -49,6 +49,7 @@ export interface StartCLIOptions {
port: string;
host: string;
hotOnly: boolean;
open: boolean;
}
export interface BuildCLIOptions {

View file

@ -70,11 +70,13 @@ cli
'--hot-only',
'Do not fallback to page refresh if hot reload fails (default: false)',
)
.action((siteDir = '.', {port, host, hotOnly}) => {
.option('--no-open', 'Do not open page in the browser (default: false)')
.action((siteDir = '.', {port, host, hotOnly, open}) => {
wrapCommand(start)(path.resolve(siteDir), {
port,
host,
hotOnly,
open,
});
});

View file

@ -144,7 +144,7 @@ export async function start(
if (err) {
console.log(err);
}
openBrowser(openUrl);
cliOptions.open && openBrowser(openUrl);
});
['SIGINT', 'SIGTERM'].forEach(sig => {
process.on(sig as NodeJS.Signals, () => {

View file

@ -48,6 +48,7 @@ Builds and serves the static site with [Webpack Dev Server](https://webpack.js.o
|`--port`|`3000`|Specifies the port of the dev server|
|`--host`|`localhost`|Specify a host to use. E.g., if you want your server to be accessible externally, you can use `--host 0.0.0.0`|
|`--hot-only`|`false`|Enables Hot Module Replacement without page refresh as fallback in case of build failures. More information [here](https://webpack.js.org/configuration/dev-server/#devserverhotonly).|
|`--no-open`|`false`|Do not open automatically the page in the browser.|
### `docusaurus build`