Skip to content

Commit a4e359e

Browse files
committed
Add reload of env after writing deployment info
1 parent 4fb3d55 commit a4e359e

2 files changed

Lines changed: 25 additions & 1 deletion

File tree

commands/deployment.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ var deploymentCommand = &console.Command{
3232
macro.WriteDeploymentInfo(repo)
3333
}
3434

35+
env.Reload()
36+
3537
macro.ComposerInstall()
3638
macro.CheckRequirements()
3739
macro.ComposerDumpEnv()

env/environment.go

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88

99
type Environment struct {
1010
variables map[string]string
11+
directory string
1112
}
1213

1314
func (e *Environment) Lookup(key string) (string, bool) {
@@ -59,7 +60,7 @@ func (e *Environment) Environ() []string {
5960
return env
6061
}
6162

62-
func NewEnvironment(directory string) (*Environment, error) {
63+
func load(directory string) (map[string]string, error) {
6364
envMap := map[string]string{}
6465

6566
err := loadFile(envMap, directory, ".env")
@@ -102,7 +103,28 @@ func NewEnvironment(directory string) (*Environment, error) {
102103
return nil, errors.Wrap(err, "failed to load PHP environment file")
103104
}
104105

106+
return envMap, nil
107+
}
108+
109+
func (e *Environment) Reload() {
110+
newEnv, err := load(e.directory)
111+
112+
if err != nil {
113+
panic(errors.Wrap(err, "failed to reload environment variables"))
114+
}
115+
116+
e.variables = newEnv
117+
}
118+
119+
func NewEnvironment(directory string) (*Environment, error) {
120+
envMap, err := load(directory)
121+
122+
if err != nil {
123+
return nil, errors.Wrap(err, "failed to load environment variables")
124+
}
125+
105126
return &Environment{
127+
directory: directory,
106128
variables: envMap,
107129
}, nil
108130
}

0 commit comments

Comments
 (0)