Skip to content

Commit

Permalink
better test for existence of .Rprofile
Browse files Browse the repository at this point in the history
  • Loading branch information
Bruno Rodrigues committed Sep 27, 2024
1 parent 44845c6 commit f7f1ac2
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions R/rix_init.R
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,12 @@ rix_init <- function(project_path,
# signal message if not quiet
message_r_session_nix_rstudio(is_nix_r, is_rstudio, message_type)

rprofile_exists <- `!=`(file.size(rprofile_file), 0)
# Test for existence and size instead of only existence,
# as an active file connection makes the file exist, but is empty
# Consider empty files as not existing to avoid not writing
# .Rprofile
rprofile_exists <- (file.exists(rprofile_file) &
`!=`(file.size(rprofile_file), 0))

Check warning on line 173 in R/rix_init.R

View workflow job for this annotation

GitHub Actions / style_pkg

file=R/rix_init.R,line=173,col=4,[indentation_linter] Indentation should be 24 spaces but is 4 spaces.

timestamp <- format(Sys.time(), "%Y-%m-%dT%H:%M:%S%z")
rprofile_backup <- paste0(rprofile_file, "_backup_", timestamp)
Expand Down Expand Up @@ -222,7 +227,6 @@ rix_init <- function(project_path,
}
},
append = {
#writeLines(paste0(rprofile_text, "\n"), rprofile_con, mode = "a+")
write_rprofile(rprofile_text, rprofile_file = rprofile_file, "a+")
message_rprofile(
action_string = "Appended", project_path = project_path
Expand Down

0 comments on commit f7f1ac2

Please sign in to comment.