feat(cli): add --no-open flag

- Flag to enable not opening the browser (different than --ci)
This commit is contained in:
Yann Braga 2021-08-03 00:40:53 +02:00
parent df7b3f84d6
commit c66573a813
4 changed files with 6 additions and 1 deletions

View File

@ -26,6 +26,7 @@ Usage: start-storybook [options]
| --ssl-key `<key>` | Provide an SSL key. (Required with --https) | `start-storybook --ssl-key my-ssl-key` |
| --smoke-test | Exit after successful start | `start-storybook --smoke-test` |
| --ci | CI mode (skip interactive prompts, don't open browser) | `start-storybook --ci` |
| --no-open | Do not open Storybook automatically in the browser | `start-storybook --no-open` |
| --quiet | Suppress verbose build output | `start-storybook --quiet` |
| --no-dll | Do not use dll reference (no-op) | `start-storybook --no-dll` |
| --debug-webpack | Display final webpack configurations for debugging purposes | `start-storybook --debug-webpack` |

View File

@ -134,6 +134,7 @@ export interface CLIOptions {
sslKey?: string;
smokeTest?: boolean;
managerCache?: boolean;
open?: boolean;
ci?: boolean;
loglevel?: string;
quiet?: boolean;

View File

@ -29,6 +29,7 @@ export async function getDevCli(packageJson: {
.option('--ssl-key <key>', 'Provide an SSL key. (Required with --https)')
.option('--smoke-test', 'Exit after successful start')
.option('--ci', "CI mode (skip interactive prompts, don't open browser)")
.option('--no-open', 'Do not open Storybook automatically in the browser')
.option('--loglevel <level>', 'Control level of logging during build')
.option('--quiet', 'Suppress verbose build output')
.option('--no-version-updates', 'Suppress update check', true)

View File

@ -90,7 +90,9 @@ export async function storybookDevServer(options: Options) {
]);
// TODO #13083 Remove this when compiling the preview is fast enough
if (!options.ci && !options.smokeTest) openInBrowser(host ? networkAddress : address);
if (!options.ci && !options.smokeTest && options.open) {
openInBrowser(host ? networkAddress : address);
}
return { previewResult, managerResult, address, networkAddress };
}