@@ -4,24 +4,34 @@ import (
4
4
"os"
5
5
6
6
"github.com/pkg/errors"
7
+ "path/filepath"
7
8
)
8
9
9
10
// ComposerExecutor returns an Executor prepared to run Symfony Console.
10
11
// It returns an error if no console binary is found.
11
12
func SymonyConsoleExecutor (args []string ) (* Executor , error ) {
12
- consolePath := "bin/console"
13
+ dir , err := os .Getwd ()
14
+ if err != nil {
15
+ return nil , errors .WithStack (err )
16
+ }
13
17
14
- if _ , err := os .Stat (consolePath ); err != nil {
15
- // Fallback to app/console for projects created with older versions of Symfony
16
- consolePath = "app/console"
18
+ for {
19
+ for _ , consolePath := range []string {"bin/console" , "app/console" } {
20
+ consolePath = filepath .Join (dir , consolePath )
21
+ if _ , err := os .Stat (consolePath ); err == nil {
22
+ return & Executor {
23
+ BinName : "php" ,
24
+ Args : append ([]string {"php" , consolePath }, args ... ),
25
+ }, nil
26
+ }
27
+ }
17
28
18
- if _ , err2 := os .Stat (consolePath ); err2 != nil {
19
- return nil , errors .WithStack (err )
29
+ upDir := filepath .Dir (dir )
30
+ if upDir == dir || upDir == "." {
31
+ break
20
32
}
33
+ dir = upDir
21
34
}
22
35
23
- return & Executor {
24
- BinName : "php" ,
25
- Args : append ([]string {"php" , consolePath }, args ... ),
26
- }, nil
36
+ return nil , errors .New ("No console binary found" )
27
37
}
0 commit comments