diff options
| author | George Kelly <gdog.kelly@googlemail.com> | 2017-11-27 19:48:31 +0000 |
|---|---|---|
| committer | George Kelly <gdog.kelly@googlemail.com> | 2017-11-27 20:04:33 +0000 |
| commit | 2e96ae1c9bde571978c30430dcd6e3f5f9807f43 (patch) | |
| tree | c128462abbb9c1a004590cc6d96185f8de0b00b0 /gomplate.go | |
| parent | 0e33e6fc712d31b742f470cc69d4166c2804ee5e (diff) | |
Can now take multiple exclude flags
Diffstat (limited to 'gomplate.go')
| -rw-r--r-- | gomplate.go | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/gomplate.go b/gomplate.go index 45cb2548..d1c6bb68 100644 --- a/gomplate.go +++ b/gomplate.go @@ -46,7 +46,7 @@ func runTemplate(o *GomplateOpts) error { g := NewGomplate(d, o.lDelim, o.rDelim) - excludeList, err := filepath.Glob(o.excludeGlob) + excludeList, err := executeCombinedGlob(o.excludeGlob) if err != nil { return err } @@ -69,3 +69,19 @@ func renderTemplate(g *Gomplate, inString string, outPath string) error { err = g.RunTemplate(inString, outFile) return err } + +// takes an array of glob strings and executes it as a whole, +// returning a merged list of globbed files +func executeCombinedGlob(globArray []string) ([]string, error) { + var combinedExcludes []string + for _, glob := range globArray { + excludeList, err := filepath.Glob(glob) + if err != nil { + return nil, err + } + + combinedExcludes = append(combinedExcludes, excludeList...) + } + + return combinedExcludes, nil +} |
