Skip to content

Commit 329fdff

Browse files
committed
Fix multiline commands in RUN not being concatenated together by &&.
Close #4 and Close #5 (h/t @nathansam)
1 parent 62fc265 commit 329fdff

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

R/dockerfile-instructions.R

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,10 @@ dfi_from <- function(dockerfile, image, as = NULL) {
8787
#' @export
8888
dfi_run <- function(dockerfile, commands) {
8989
check_dockerfile(dockerfile)
90-
add_dockerfile_line(dockerfile, "RUN", commands)
90+
91+
# Join multiple commands with &&
92+
command_str <- paste(commands, collapse = " && ")
93+
add_dockerfile_line(dockerfile, "RUN", command_str)
9194
}
9295

9396
#' Add a `COPY` instruction to a `dockerfile`

tests/testthat/test-dockerfile-instructions.R

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ test_that("dfi_run(): adds RUN instruction correctly", {
2626

2727
# Multiple commands
2828
df <- dfi_run(df, c("apt-get update", "apt-get install -y curl"))
29-
expect_equal(df$lines[2], "RUN apt-get update")
30-
expect_equal(df$lines[3], " apt-get install -y curl")
29+
expect_equal(df$lines[2], "RUN apt-get update && apt-get install -y curl")
3130
})
3231

3332
# Test dfi_copy() ----

0 commit comments

Comments
 (0)