Skip to content

Commit

Permalink
Merge pull request #18 from wharfr/image-cmd-env
Browse files Browse the repository at this point in the history
Expose the project dir to the image-cmd script
  • Loading branch information
qur committed Oct 8, 2019
2 parents 63361b7 + 73e2b40 commit dad3e98
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/config/crate.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ func GetCrate(start, name string, ls LabelSource) (*Crate, error) {
}

func runImageCmd(command string, projectDir string) (string, error) {
command = strings.TrimSpace(command)
shell := []string{"sh"}
if strings.HasPrefix(command, "#!") {
hashBang := strings.Split(command, "\n")[0]
Expand All @@ -115,6 +116,9 @@ func runImageCmd(command string, projectDir string) (string, error) {
cmd.Stdin = strings.NewReader(command)
cmd.Stdout = buf
cmd.Stderr = os.Stderr
cmd.Env = append(os.Environ(),
"WHARFRAT_PROJECT_DIR=" + projectDir,
)
if err := cmd.Run(); err != nil {
return "", err
}
Expand Down

0 comments on commit dad3e98

Please sign in to comment.