Skip to content

Commit

Permalink
Update to support windows line breaks. Fixes #35 (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickdappollonio authored Mar 11, 2022
1 parent 3cef5d9 commit 1bd169f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 4 additions & 1 deletion slice/execute.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,12 @@ func (s *Split) scan() error {
// If we reached the end of file, handle up to this point
if err == io.EOF {
s.log.Println("Reached end of file while parsing. Sending remaining buffer to process.")
fmt.Fprint(&local, line)

if err := parseFile(); err != nil {
return err
}

s.fileCount++
break
}
Expand All @@ -129,7 +132,7 @@ func (s *Split) scan() error {
}

// Check if we're at the end of the file
if line == "---\n" {
if line == "---\n" || line == "---\r\n" {
s.log.Println("Found the end of a file. Sending buffer to process.")
if err := parseFile(); err != nil {
return err
Expand Down
8 changes: 8 additions & 0 deletions slice/split_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ foo: baz
---
bar: baz`

var allInOneCRLF = "foo: bar\r\n---\r\nfoo: baz\r\n---\r\nbar: baz\r\n"

var allInOneOutput = map[string]string{
"example.yaml": `foo: bar
Expand Down Expand Up @@ -175,6 +177,12 @@ func TestEndToEnd(t *testing.T) {
template: "example.yaml",
expectedFiles: allInOneOutput,
},
{
name: "everything in a single file, CRLF",
inputFile: allInOneCRLF,
template: "example.yaml",
expectedFiles: allInOneOutput,
},
}

createTempYAML := func(contents string) (string, error) {
Expand Down

0 comments on commit 1bd169f

Please sign in to comment.