Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add command environment variables config #9

Merged
merged 1 commit into from
Apr 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ build_delay: 200ms
binary_name: refresh-build
# any extra commands you want to send to the built binary when it is run:
command_flags: []
# any extra environment variables you want to send to the built binary when it is run:
command_env: []
# do you want to use colors when printing out log messages:
enable_colors: true
```
1 change: 1 addition & 0 deletions cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ var initCmd = &cobra.Command{
BuildDelay: 200,
BinaryName: "refresh-build",
CommandFlags: []string{},
CommandEnv: []string{},
EnableColors: true,
}
c.Dump(cfgFile)
Expand Down
1 change: 1 addition & 0 deletions refresh.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ build_path: /tmp
build_delay: 200ns
binary_name: refresh-build
command_flags: []
command_env: []
enable_colors: true
1 change: 1 addition & 0 deletions refresh/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type Configuration struct {
BuildDelay time.Duration `yaml:"build_delay"`
BinaryName string `yaml:"binary_name"`
CommandFlags []string `yaml:"command_flags"`
CommandEnv []string `yaml:"command_env"`
EnableColors bool `yaml:"enable_colors"`
LogName string `yaml:"log_name"`
}
Expand Down
5 changes: 5 additions & 0 deletions refresh/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ func (m *Manager) runAndListen(cmd *exec.Cmd) error {
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout

// Set the environment variables from config
if len(m.CommandEnv) != 0 {
cmd.Env = append(m.CommandEnv, os.Environ()...)
}

err := cmd.Start()
if err != nil {
return fmt.Errorf("%s\n%s", err, stderr.String())
Expand Down