Skip to content

feat: support open_url boolean flag to launch browser automatically - #293

Open
HigorMonteiro wants to merge 1 commit into
lepture:masterfrom
HigorMonteiro:feat/auto-open-browser
Open

HigorMonteiro wants to merge 1 commit into
lepture:masterfrom
HigorMonteiro:feat/auto-open-browser

Conversation

@HigorMonteiro

Copy link
Copy Markdown

🎯 Problem

The Server.serve() signature includes an open_url parameter, but passing open_url=True currently does not open the browser. Instead, it only logs an error:
Use open_url_delay instead of open_url.

For developers and CLI tools using livereload, requiring an explicit delay in seconds (open_url_delay) when they simply want to open the browser on startup is unintuitive and breaks expectations.

💡 Solution

  1. In livereload/server.py: If open_url=True and open_url_delay is None, default delay to 0 so the browser opens automatically upon startup.
  2. Preserves 100% backward compatibility for users explicitly setting open_url_delay.
  3. In livereload/cli.py: Added -b / --open-url flag.
  4. Added unit test test_open_url_true_opens_browser in tests/test_server.py.

🧪 Verification

  • pytest tests/test_server.py passes.
  • Validated real-world usage in local projects with server.serve(..., open_url=True).

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant