Skip to content

Commit ebd66b2

Browse files
authored
Merge pull request #231 from tucksaun/expose-cli-version-and-name
Expose the CLI version and binary name when running `console`, `php` and `composer` wrappers
2 parents 3612ee0 + b27c38d commit ebd66b2

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_BINARY_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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy