Skip to content

Commit

Permalink
don't write to file if no change has been made
Browse files Browse the repository at this point in the history
  • Loading branch information
DyfanJones committed Jan 12, 2024
1 parent b808ad3 commit 310c5e9
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions make.paws/R/sdk_helper.R
Original file line number Diff line number Diff line change
Expand Up @@ -412,26 +412,32 @@ paws_gsub <- function(
cran_r <- lapply(
cran_pkg, \(x) fs::dir_ls(file.path(x, "R"))
)
cran_rd <- lapply(
cran_pkg, \(x) fs::dir_ls(file.path(x, "man"))
)
log_info(
"Removed escaped latex scripts from paws directory."
)

cran_file_gsub <- function(before, after, files) {
for (file in files) {
result <- readLines(file)
result <- gsub(before, after, result)
writeLines(result, file)
found <- grep(before, after, result)
if (length(found) > 0) {
result[found] <- gsub(before, after, result[found])
writeLines(result, file)
}
}
}
for (pkg in cran_pkg) {
cran_file_gsub(before, after, cran_r[[pkg]])
log_info("Successfully update package: %s", pkg)
}
for (file in paws_r) {
result <- readLines(file)
result <- gsub(before, after, result)
writeLines(result, file)
for (pkg in cran_pkg) {
cran_file_gsub(before, after, cran_rd[[pkg]])
log_info("Successfully update package rd documentation: %s", pkg)
}
cran_file_gsub(before, after, paws_r)
}

#' @title Rebuild paws documentation
Expand Down

0 comments on commit 310c5e9

Please sign in to comment.