-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
feat: add --open to deno serve to open server in browser #25340
base: main
Are you sure you want to change the base?
Conversation
@marvinhagemeister @dsherret Is there a workaround or should I just remove the test? |
@bartlomieju @marvinhagemeister |
@@ -2875,7 +2877,7 @@ Start a server defined in server.ts, watching for changes and running on port 50 | |||
.long("host") | |||
.help("The TCP address to serve on, defaulting to 0.0.0.0 (all interfaces)") | |||
.value_parser(serve_host_validator), | |||
) | |||
).arg(Arg::new("open_site").long("open").help("Open the browser on the address that the server is running on.").action(ArgAction::SetTrue)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you run tools/format.js
before pushing? This seems not formatted
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes I did, and did it again now, still the same.
cli/tools/serve.rs
Outdated
log::info!( | ||
"{}: Opened the browser on the address that the server is running on", | ||
crate::colors::green("deno serve") | ||
); | ||
} else { | ||
log::info!("{}: Couldn't open the browser on the address that the server is running on", crate::colors::red("deno serve")); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if it worth adding these logs here, does Vite or other tools do it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked Vite, it doesn't log on success, but logs "e.g. (Permission denied)" on failure.
Deno already shows logs on failure of serve, so you're right. No need for these logs
tests/integration/serve_tests.rs
Outdated
|
||
// Check if a new browser tab has been opened by checking | ||
// stderr includes the target output expected | ||
fn check_tab_opened(&self) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if this test makes sense - on CI there will be no browser to open, while locally people will suddenly get some new tabs. I'd suggest to not add it at all.
…/deno into open-flag-on-serve
@bartlomieju |
@bartlomieju |
Bumping this ^ @bartlomieju |
This PR addresses issue number #25149
Change:
Supported --open flag with deno serve -> (deno serve --open somescript.ts/js).
The action that takes place is openning the browser on the address that the server is running on.
Changes on code:
Concerns:
The window tab will be opened on deno serve command no matter whether deno serve succeeds or fails.
The added test since it's a serve command then it starts listening for a request and never shuts down, I couldn't figure out how to shut it down same as other serve tests.