8000 Merge pull request #192 from symfony-cli/domain-local-open · symfony-cli/symfony-cli@6c9ba88 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6c9ba88

Browse files
authored
Merge pull request #192 from symfony-cli/domain-local-open
Use the first configured domain when available with local:open
2 parents cccfdaf + ec17e2a commit 6c9ba88

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

commands/openers.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ import (
2727
"github.com/symfony-cli/console"
2828
"github.com/symfony-cli/symfony-cli/envs"
2929
"github.com/symfony-cli/symfony-cli/local/pid"
30+
"github.com/symfony-cli/symfony-cli/local/proxy"
31+
"github.com/symfony-cli/symfony-cli/util"
3032
"github.com/symfony-cli/terminal"
3133
)
3234

@@ -60,9 +62,16 @@ var projectLocalOpenCmd = &console.Command{
6062
if !pidFile.IsRunning() {
6163
return console.Exit("Local web server is down.", 1)
6264
}
63-
abstractOpenCmd(fmt.Sprintf("%s://127.0.0.1:%d/%s",
65+
host := fmt.Sprintf("127.0.0.1:%d", pidFile.Port)
66+
if proxyConf, err := proxy.Load(util.GetHomeDir()); err == nil {
67+
domains := proxyConf.GetDomains(projectDir)
68+
if len(domains) > 0 {
69+
host = domains[0]
70+
}
71+
}
72+
abstractOpenCmd(fmt.Sprintf("%s://%s/%s",
6473
pidFile.Scheme,
65-
pidFile.Port,
74+
host,
6675
strings.TrimLeft(c.String("path"), "/"),
6776
))
6877
return nil

0 commit comments

Comments
 (0)
0