Skip to content

Commit

Permalink
source: allow inline env vars in build
Browse files Browse the repository at this point in the history
  • Loading branch information
akupila committed Apr 6, 2020
1 parent 811244a commit 21b3ed0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
10 changes: 8 additions & 2 deletions source/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,14 @@ func ParseBuildScript(str string) (BuildScript, error) {
continue
}
parts := strings.Split(line, " ")
if _, err := exec.LookPath(parts[0]); err != nil {
return nil, fmt.Errorf("line %d: %w", i, err)
for _, part := range parts {
if strings.Contains(part, "=") {
continue
}
if _, err := exec.LookPath(part); err != nil {
return nil, fmt.Errorf("line %d: %w", i, err)
}
break
}
out = append(out, BuildStep(line))
}
Expand Down
7 changes: 7 additions & 0 deletions source/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ func TestParseBuildScript(t *testing.T) {
input: "thisfiledoesnotexist --xx --yy",
wantErr: true,
},
{
name: "EnvVar",
input: "FOO=bar echo $FOO",
want: BuildScript{
"FOO=bar echo $FOO",
},
},
{
name: "Empty",
input: "",
Expand Down

0 comments on commit 21b3ed0

Please sign in to comment.