diff --git a/R/package.R b/R/package.R index f94e3f7787..dc7b5396ae 100644 --- a/R/package.R +++ b/R/package.R @@ -9,6 +9,7 @@ #' @export as_pkgdown <- function(pkg = ".", override = list()) { if (is_pkgdown(pkg)) { + pkg$meta <- modify_list(pkg$meta, override) return(pkg) } @@ -21,7 +22,7 @@ as_pkgdown <- function(pkg = ".", override = list()) { desc <- read_desc(pkg) meta <- read_meta(pkg) - meta <- utils::modifyList(meta, override) + meta <- modify_list(meta, override) template_config <- find_template_config( package = meta$template$package, diff --git a/R/utils.R b/R/utils.R index 2907481264..ae11e99c71 100644 --- a/R/utils.R +++ b/R/utils.R @@ -86,7 +86,9 @@ isFALSE <- function(x) { } modify_list <- function(x, y) { - if (is.null(y)) { + if (is.null(x)) { + return(y) + } else if (is.null(y)) { return(x) } diff --git a/tests/testthat/test-package.R b/tests/testthat/test-package.R index 01fef0a4f2..b2b0f417d2 100644 --- a/tests/testthat/test-package.R +++ b/tests/testthat/test-package.R @@ -48,6 +48,15 @@ test_that("package_vignettes() sorts articles alphabetically by file name", { ) }) +test_that("override works correctly for as_pkgdown", { + pkgdown <- as_pkgdown("assets/man-figures") + expected_list <- list(figures = list(dev = "jpeg", fig.ext = "jpg", fig.width = 3, fig.asp = 1)) + expect_equal(pkgdown$meta, expected_list) + modified_pkgdown <- as_pkgdown(pkgdown, override = list(figures = list(dev = "png"))) + modified_list <- list(figures = list(dev = "png", fig.ext = "jpg", fig.width = 3, fig.asp = 1)) + modified_pkgdown$meta + expect_equal(modified_pkgdown$meta, modified_list) +}) # titles ------------------------------------------------------------------ test_that("multiline titles are collapsed", {