Skip to content

Commit 496f238

Browse files
committed
Revert "Revert "Add command environment variables config""
This reverts commit 25435da.
1 parent ac43101 commit 496f238

File tree

5 files changed

+10
-0
lines changed

5 files changed

+10
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ build_target_path : ""
7676
binary_name: refresh-build
7777
# any extra commands you want to send to the built binary when it is run:
7878
command_flags: []
79+
# any extra environment variables you want to send to the built binary when it is run:
80+
command_env: []
7981
# do you want to use colors when printing out log messages:
8082
enable_colors: true
8183
```

cmd/init.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ var initCmd = &cobra.Command{
2424
BuildDelay: 200,
2525
BinaryName: "refresh-build",
2626
CommandFlags: []string{},
27+
CommandEnv: []string{},
2728
EnableColors: true,
2829
}
2930
c.Dump(cfgFile)

refresh.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ build_path: /tmp
99
build_delay: 200ns
1010
binary_name: refresh-build
1111
command_flags: []
12+
command_env: []
1213
enable_colors: true

refresh/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ type Configuration struct {
2222
BuildDelay time.Duration `yaml:"build_delay"`
2323
BinaryName string `yaml:"binary_name"`
2424
CommandFlags []string `yaml:"command_flags"`
25+
CommandEnv []string `yaml:"command_env"`
2526
EnableColors bool `yaml:"enable_colors"`
2627
LogName string `yaml:"log_name"`
2728
}

refresh/runner.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ func (m *Manager) runAndListen(cmd *exec.Cmd) error {
3636
cmd.Stdin = os.Stdin
3737
cmd.Stdout = os.Stdout
3838

39+
// Set the environment variables from config
40+
if len(m.CommandEnv) != 0 {
41+
cmd.Env = append(m.CommandEnv, os.Environ()...)
42+
}
43+
3944
err := cmd.Start()
4045
if err != nil {
4146
return fmt.Errorf("%s\n%s", err, stderr.String())

0 commit comments

Comments
 (0)