Commit 1d94e0f8 authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

template: abslute path for template path

parent 022a115d
...@@ -6,6 +6,7 @@ import ( ...@@ -6,6 +6,7 @@ import (
"fmt" "fmt"
"io" "io"
"os" "os"
"path/filepath"
"sort" "sort"
"github.com/hashicorp/go-multierror" "github.com/hashicorp/go-multierror"
...@@ -317,6 +318,13 @@ func ParseFile(path string) (*Template, error) { ...@@ -317,6 +318,13 @@ func ParseFile(path string) (*Template, error) {
return nil, err return nil, err
} }
if !filepath.IsAbs(path) {
path, err = filepath.Abs(path)
if err != nil {
return nil, err
}
}
tpl.Path = path tpl.Path = path
return tpl, nil return tpl, nil
} }
package template package template
import ( import (
"path/filepath"
"reflect" "reflect"
"strings" "strings"
"testing" "testing"
...@@ -306,7 +307,7 @@ func TestParse(t *testing.T) { ...@@ -306,7 +307,7 @@ func TestParse(t *testing.T) {
} }
for _, tc := range cases { for _, tc := range cases {
path := fixtureDir(tc.File) path, _ := filepath.Abs(fixtureDir(tc.File))
tpl, err := ParseFile(fixtureDir(tc.File)) tpl, err := ParseFile(fixtureDir(tc.File))
if (err != nil) != tc.Err { if (err != nil) != tc.Err {
t.Fatalf("err: %s", err) t.Fatalf("err: %s", err)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment