|
# TODO: We should search for both the global (home directory) and local (project directory) .Rprofiles. |
|
# TODO: This uses '~', is this portable to Windows (and is RProfile stored in the same place on Windows)? |
|
rprofile <- paste0(c('if( file.exists(path.expand("~/.Rprofile") ) ){', |
|
'source(path.expand("~/.Rprofile"))', |
|
'}', |
|
'library(CIDATools)', |
|
paste0('CIDATools::open_project(localpath="',path,'")')), |
|
collapse="\n") |
|
if(!file.exists(file.path(path,"/.Rprofile"))) |
|
writeLines(rprofile, con = file.path(path,"/.Rprofile")) |
Currently, using create_project will add a snippet of code to ~/.Rprofile (only if it doesn't exist) which will automatically open a CIDA project on initialization.
This means that the first project which is created with CIDAtools will always be opened by the global Rprofile.
We should:
- Change this to use the project-level .Rprofile only
- Adding the snippet will only happen if the .Rprofile file doesn't exist, but in many cases an Rprofile may already exist or be created by something else (like
renv)
- We should instead add a grep-able comment to the snippet (i.e.
#CIDATOOLS_ADDED: Automatic Project Opening), then check for this snippet and always append to .Rprofile if we don't find it (or .Rprofile doesn't exist).
CIDAtools/R/project.R
Lines 311 to 320 in e84bb43
Currently, using
create_projectwill add a snippet of code to~/.Rprofile(only if it doesn't exist) which will automatically open a CIDA project on initialization.This means that the first project which is created with CIDAtools will always be opened by the global Rprofile.
We should:
renv)#CIDATOOLS_ADDED: Automatic Project Opening), then check for this snippet and always append to .Rprofile if we don't find it (or .Rprofile doesn't exist).