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

Feat: add --open to deno serve to open server in browser #25149

Open
marvinhagemeister opened this issue Aug 22, 2024 · 2 comments
Open

Feat: add --open to deno serve to open server in browser #25149

marvinhagemeister opened this issue Aug 22, 2024 · 2 comments
Labels
feat new feature (which has been agreed to/accepted)

Comments

@marvinhagemeister
Copy link
Contributor

Most dev servers allow you to pass --open to open the page automatically in the browser. It's a neat minor DX enhancement compared to having to click the link yourself.

When passing deno serve --open the browser should open the address where the server is running on. Vite goes a bit the extra mile to ensure that the same tab is re-used via some apple script vodoo https://github.com/vitejs/vite/blob/561b940f6f963fbb78058a6e23b4adad53a2edb9/packages/vite/src/node/server/openBrowser.ts#L71-L141

@marvinhagemeister marvinhagemeister added the feat new feature (which has been agreed to/accepted) label Aug 22, 2024
@bartlomieju
Copy link
Member

No strong feeling either way, seems like a cool feature.

We already have a dependency crate that handles opening the browser, an example usage is here:

log::info!("{}", colors::gray("Waiting..."));
let _ = open::that_detached(&auth_url);

@HasanAlrimawi
Copy link
Contributor

HasanAlrimawi commented Aug 29, 2024

I'm working on it if still possible.
I've done half the way (supported the --open, also added it to ServeFlags, as well as opened browser based on the host and port found at least made sure it works for localhost, it should work for servers too ).
Just trying to figure out how to only open the browser on success of the deno serve, since sometimes the deno serve shows error and the site shows unreachable message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat new feature (which has been agreed to/accepted)
Projects
None yet
Development

No branches or pull requests

3 participants