Skip to content

Commit

Permalink
Merge pull request #7 from racklet/quote_output
Browse files Browse the repository at this point in the history
Quote the files when output
  • Loading branch information
twelho authored Jun 10, 2021
2 parents 617d830 + eb661a7 commit 7c2a99a
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
FROM golang:1.16-alpine as builder
WORKDIR /build
COPY . .
# Make sure tests pass before building :)
RUN CGO_ENABLED=0 go test ./...
RUN CGO_ENABLED=0 go build -a -o render-drawio ./cmd/render-drawio

FROM rlespinasse/drawio-desktop-headless:1.0.1
Expand Down
9 changes: 8 additions & 1 deletion pkg/render/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,13 @@ func GitHubActionSetFilesOutput(key, rootDir string, files []string) error {
}
}
// Run the generic function
GitHubActionSetOutput(key, strings.Join(files, " "))
GitHubActionSetOutput(key, joinQuotedStrings(files))
return nil
}

func joinQuotedStrings(strs []string) string {
for i := range strs {
strs[i] = fmt.Sprintf("%q", strs[i])
}
return strings.Join(strs, " ")
}
24 changes: 24 additions & 0 deletions pkg/render/render_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package render

import "testing"

func Test_joinQuotedStrings(t *testing.T) {
tests := []struct {
name string
strs []string
want string
}{
{
name: "simple",
strs: []string{"foo bar", "bar baz"},
want: `"foo bar" "bar baz"`,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := joinQuotedStrings(tt.strs); got != tt.want {
t.Errorf("joinQuotedStrings() = %v, want %v", got, tt.want)
}
})
}
}

0 comments on commit 7c2a99a

Please sign in to comment.