Skip to content

Commit

Permalink
Writing output files from a stdin template requires permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
ben dewan committed Apr 23, 2018
1 parent 13cef44 commit aedc3c8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions template.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ func gatherTemplates(o *Config) (templates []*tplate, err error) {
templates = []*tplate{{
name: "<arg>",
contents: o.Input,
mode: os.FileMode(0644),
}}

if len(o.OutputFiles) == 1 {
Expand Down
9 changes: 9 additions & 0 deletions template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,15 @@ func TestGatherTemplates(t *testing.T) {
assert.Equal(t, "foo", templates[0].contents)
assert.Equal(t, Stdout, templates[0].target)

templates, err = gatherTemplates(&Config{
Input: "foo",
OutputFiles: []string{"out"},
})
assert.NoError(t, err)
assert.Len(t, templates, 1)
assert.Equal(t, "out", templates[0].targetPath)
assert.Equal(t, os.FileMode(0644), templates[0].mode)

templates, err = gatherTemplates(&Config{
InputFiles: []string{"foo"},
OutputFiles: []string{"out"},
Expand Down

0 comments on commit aedc3c8

Please sign in to comment.