Skip to content

Commit

Permalink
Provide a way to force site cleaning
Browse files Browse the repository at this point in the history
Fixes #2699
  • Loading branch information
jayhesselberth committed Nov 29, 2024
1 parent 7a6ffe4 commit 7513ea8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 4 additions & 3 deletions R/clean.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
#' Delete all files in `docs/` (except for `CNAME`).
#'
#' @param quiet If `TRUE`, suppresses a message.
#' @param force If `TRUE`, delete contents of `docs` even if it is not a pkgdown site.
#' @inheritParams build_site
#' @rdname clean
#' @export
clean_site <- function(pkg = ".", quiet = FALSE) {
clean_site <- function(pkg = ".", quiet = FALSE, force = FALSE) {

pkg <- as_pkgdown(pkg)

Expand All @@ -17,7 +18,7 @@ clean_site <- function(pkg = ".", quiet = FALSE) {
if (!dir_exists(pkg$dst_path)) return(invisible())

top_level <- dest_files(pkg)
if (length(top_level) > 0) {
if (length(top_level) > 0 && !force) {
check_dest_is_pkgdown(pkg)
}

Expand Down Expand Up @@ -60,7 +61,7 @@ check_dest_is_pkgdown <- function(pkg) {
cli::cli_abort(c(
"{.file {pkg$dst_path}} is non-empty and not built by pkgdown",
"!" = "Make sure it contains no important information \\
and use {.run pkgdown::clean_site()} to delete its contents."
and use {.run pkgdown::clean_site(force = TRUE)} to delete its contents."
)
)
}
Expand Down
4 changes: 3 additions & 1 deletion man/clean.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7513ea8

Please sign in to comment.