Skip to content

Commit 86d68b8

Browse files
committed
Add dependency check for Symfony framework in server start/stop commands
1 parent 1900e99 commit 86d68b8

2 files changed

Lines changed: 20 additions & 12 deletions

File tree

macro/symfony_server_start.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
11
package macro
22

33
import (
4+
"github.com/SoureCode/kyx/project"
45
"github.com/SoureCode/kyx/shell"
56
"github.com/pkg/errors"
67
)
78

89
func SymfonyServerStart() {
910
logger := shell.GetLogger()
11+
p := project.GetProject()
1012

11-
cmd, err := shell.NewSymfonyCommand("serve", "--daemon")
13+
if p.HasDependency("symfony/framework-bundle") {
14+
cmd, err := shell.NewSymfonyCommand("serve", "--daemon")
1215

13-
if err != nil {
14-
panic(errors.Wrap(err, "failed to create Symfony command to start server"))
15-
}
16+
if err != nil {
17+
panic(errors.Wrap(err, "failed to create Symfony command to start server"))
18+
}
1619

17-
if err = cmd.WithLogger(logger).Run(); err != nil {
18-
panic(errors.Wrap(err, "failed to execute command to start server"))
20+
if err = cmd.WithLogger(logger).Run(); err != nil {
21+
panic(errors.Wrap(err, "failed to execute command to start server"))
22+
}
1923
}
2024
}

macro/symfony_server_stop.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
11
package macro
22

33
import (
4+
"github.com/SoureCode/kyx/project"
45
"github.com/SoureCode/kyx/shell"
56
"github.com/pkg/errors"
67
)
78

89
func SymfonyServerStop() {
910
logger := shell.GetLogger()
11+
p := project.GetProject()
1012

11-
cmd, err := shell.NewSymfonyCommand("server:stop")
13+
if p.HasDependency("symfony/framework-bundle") {
14+
cmd, err := shell.NewSymfonyCommand("server:stop")
1215

13-
if err != nil {
14-
panic(errors.Wrap(err, "failed to create Symfony command to stop server"))
15-
}
16+
if err != nil {
17+
panic(errors.Wrap(err, "failed to create Symfony command to stop server"))
18+
}
1619

17-
if err = cmd.WithLogger(logger).Run(); err != nil {
18-
panic(errors.Wrap(err, "failed to execute command to stop server"))
20+
if err = cmd.WithLogger(logger).Run(); err != nil {
21+
panic(errors.Wrap(err, "failed to execute command to stop server"))
22+
}
1923
}
2024
}

0 commit comments

Comments
 (0)