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

CLI: Add --no-open flag #15739

Merged
merged 1 commit into from Aug 3, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/api/cli-options.md
Expand Up @@ -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` |
Expand Down
1 change: 1 addition & 0 deletions lib/core-common/src/types.ts
Expand Up @@ -134,6 +134,7 @@ export interface CLIOptions {
sslKey?: string;
smokeTest?: boolean;
managerCache?: boolean;
open?: boolean;
ci?: boolean;
loglevel?: string;
quiet?: boolean;
Expand Down
1 change: 1 addition & 0 deletions lib/core-server/src/cli/dev.ts
Expand Up @@ -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')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be --open? @yannbf

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to commander's docs that's how you set a flag that is true by default and will be set to false when used. With this option set, --open will not be recognized, only --no-open. However, when would anyone ever use the flag --open if that is true by default? 🤔

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

.option('--loglevel <level>', 'Control level of logging during build')
.option('--quiet', 'Suppress verbose build output')
.option('--no-version-updates', 'Suppress update check', true)
Expand Down
4 changes: 3 additions & 1 deletion lib/core-server/src/dev-server.ts
Expand Up @@ -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 };
}