Skip to content

Open browser when starting preview #36

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

Merged
merged 1 commit into from
Jul 20, 2023
Merged

Open browser when starting preview #36

merged 1 commit into from
Jul 20, 2023

Conversation

kyntk
Copy link
Contributor

@kyntk kyntk commented Jul 19, 2023

What

  • previewを起動したときにブラウザを開くようにした
    • previewを起動する際にはブラウザで確認したいので、ブラウザを開く手間を削減するため

How

Why

addressがnullもしくはstringの場合は意図していない状態なのでブラウザを起動しない

  const address = server.address();
  if (address && typeof address !== "string") {

https://nodejs.org/api/net.html#serveraddress

Refs

  • 以下のブラウザで起動することを確認 (Mac)
    • Chrome
    • Safari
    • Firefox
    • Edge
  • サーバーの起動に失敗したときにはブラウザは立ち上がらない

@kyntk kyntk self-assigned this Jul 19, 2023
@kyntk kyntk marked this pull request as ready for review July 19, 2023 10:08
@kyntk kyntk requested review from a team and atm-snag2 and removed request for a team July 20, 2023 02:36
@kyntk kyntk force-pushed the open-browser-in-preview branch from 162ad65 to bdf52c0 Compare July 20, 2023 06:55
Copy link
Contributor

@atm-snag2 atm-snag2 left a comment

Choose a reason for hiding this comment

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

LGTM

@kyntk kyntk merged commit a0620ac into main Jul 20, 2023
@kyntk kyntk deleted the open-browser-in-preview branch July 20, 2023 07:32
@ohakutsu ohakutsu mentioned this pull request Jul 21, 2023
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.

2 participants