Skip to content

Commit 32a3d89

Browse files
committed
Expose the CLI version and binary name when running console, php and composer wrappers
Exposing those info via environment variables will allow better Symfony Maker experience, see symfony/maker-bundle#1238
1 parent c0980f3 commit 32a3d89

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

main.go

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@ var (
4343
buildDate string
4444
)
4545

46+
func getCliExtraEnv() []string {
47+
return []string{
48+
"SYMFONY_CLI_VERSION=" + version,
49+
"SYMFONY_CLI_BIN_NAME=" + console.CurrentBinaryName(),
50+
}
51+
}
52+
4653
func main() {
4754
args := os.Args
4855
name := console.CurrentBinaryName()
@@ -55,8 +62,9 @@ func main() {
5562
// called via "symfony php"?
5663
if len(args) >= 2 && php.IsBinaryName(args[1]) {
5764
e := &php.Executor{
58-
BinName: args[1],
59-
Args: args[1:],
65+
BinName: args[1],
66+
Args: args[1:],
67+
ExtraEnv: getCliExtraEnv(),
6068
}
6169
os.Exit(e.Execute(true))
6270
}
@@ -67,14 +75,15 @@ func main() {
6775
args[1] = "app/console"
6876
}
6977
e := &php.Executor{
70-
BinName: "php",
71-
Args: args,
78+
BinName: "php",
79+
Args: args,
80+
ExtraEnv: getCliExtraEnv(),
7281
}
7382
os.Exit(e.Execute(false))
7483
}
7584
// called via "symfony composer"?
7685
if len(args) >= 2 && args[1] == "composer" {
77-
res := php.Composer("", args[2:], []string{}, os.Stdout, os.Stderr, ioutil.Discard, zerolog.Nop())
86+
res := php.Composer("", args[2:], getCliExtraEnv(), os.Stdout, os.Stderr, ioutil.Discard, zerolog.Nop())
7887
terminal.Eprintln(res.Error())
7988
os.Exit(res.ExitCode())
8089
}

0 commit comments

Comments
 (0)