Skip to content

Commit 300cb66

Browse files
committed
Fix newline after heredocs
1 parent 790e4f9 commit 300cb66

File tree

6 files changed

+13
-7
lines changed

6 files changed

+13
-7
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Binaries are available from the [releases](https://github.com/reteps/dockerfmt/r
1212
A updated version of the dockfmt. Uses the dockerfile parser from moby/buildkit and the shell formatter from mvdan/sh.
1313
1414
Usage:
15-
dockerfmt [Dockerfile] [flags]
15+
dockerfmt [Dockerfile...] [flags]
1616
dockerfmt [command]
1717
1818
Available Commands:

cmd/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ var versionCmd = &cobra.Command{
1414
Use: "version",
1515
Short: "Print the version number of dockerfmt",
1616
Run: func(cmd *cobra.Command, args []string) {
17-
fmt.Println("dockerfmt 0.3.4")
17+
fmt.Println("dockerfmt 0.3.5")
1818
},
1919
}

js/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@reteps/dockerfmt",
3-
"version": "0.3.4",
3+
"version": "0.3.5",
44
"type": "module",
55
"description": "",
66
"repository": "git+https://github.com/reteps/dockerfmt/tree/main/js",

lib/format.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,6 @@ func GetHeredoc(n *ExtendedNode) (string, bool) {
406406
}
407407
cur = cur.Next
408408
}
409-
410409
content := strings.Join(args, " ") + "\n" + n.Node.Heredocs[0].Content + n.Node.Heredocs[0].Name + "\n"
411410
return content, true
412411
}
@@ -520,9 +519,10 @@ func formatSpaceSeparated(n *ExtendedNode, c *Config) string {
520519
if len(n.Node.Flags) > 0 {
521520
cmd = strings.Join(n.Node.Flags, " ") + " " + cmd
522521
}
522+
cmd += "\n"
523523
}
524524

525-
return strings.ToUpper(n.Node.Value) + " " + cmd + "\n"
525+
return strings.ToUpper(n.Node.Value) + " " + cmd
526526
}
527527

528528
func formatMaintainer(n *ExtendedNode, c *Config) string {

tests/in/heredoc.dockerfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,8 @@ EOF
1515

1616
COPY <<-EOT /script.sh
1717
echo "hello ${FOO}"
18-
EOT
18+
EOT
19+
COPY <<-EOF /x
20+
x
21+
EOF
22+

tests/out/heredoc.dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ COPY <<-EOF /x
1313
x
1414
EOF
1515

16-
1716
COPY <<-EOT /script.sh
1817
echo "hello ${FOO}"
1918
EOT
19+
COPY <<-EOF /x
20+
x
21+
EOF

0 commit comments

Comments
 (0)