Skip to content

Commit

Permalink
Update R/add_stylecss.R
Browse files Browse the repository at this point in the history
Co-authored-by: James McMahon <[email protected]>
  • Loading branch information
alan-y and Moohan authored Oct 4, 2023
1 parent e952d06 commit 2197bda
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions R/add_stylecss.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,18 @@ add_stylecss <- function(path = rstudioapi::selectDirectory(caption = "Select fo
stylecss <- paste(stylecss, collapse = "\n")

# Search for existing stylecss in path
file_exists <- file.exists(paste0(path, "/style.css"))

if (file_exists) {
write_out <- rstudioapi::showQuestion(
if (file.exists(file.path(path, "style.css"))) {
overwrite <- rstudioapi::showQuestion(
title = "Overwrite?",
message = "You already have a style.css file. Select OK if you want to overwrite this file?",
message = "A style.css file already exists. Select OK to overwrite this file."
)
} else {
write_out <- TRUE
}

if (write_out) {
writeLines(stylecss, con = paste0(path, "/style.css"))
} else {
return(message("style.css file not added."))

if (!overwrite) {
message("style.css has not been overwritten.")
return(NULL)
}
}

writeLines(stylecss, con = file.path(path, "style.css"))
return(NULL)
}

0 comments on commit 2197bda

Please sign in to comment.