Skip to content

Commit

Permalink
Add env variable expansion for includes.
Browse files Browse the repository at this point in the history
  • Loading branch information
trhodeos committed Feb 25, 2018
1 parent 0afc1ac commit 3e4a802
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import (
"fmt"
"github.com/alecthomas/participle"
"io"
"os"
"path/filepath"
"strings"
)

type Constant struct {
Expand Down Expand Up @@ -141,7 +144,11 @@ func convertSegmentAst(s *SegmentAst) (*Segment, error) {
}
break
case "include":
seg.Includes = append(seg.Includes, statement.Value.String)
// Hacky way of moving $(var) -> $var
replaced := strings.Replace(statement.Value.String, "$(", "$", -1)
replaced = strings.Replace(replaced, ")", "", -1)
replaced = filepath.Clean(os.ExpandEnv(replaced))
seg.Includes = append(seg.Includes, replaced)
break
case "maxsize":
seg.MaxSize = statement.Value.Int
Expand Down

0 comments on commit 3e4a802

Please sign in to comment.