Skip to content

golem::add_(module, fct,...) appends to file if already exists #393

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
HanjoStudy opened this issue Mar 6, 2020 · 3 comments
Closed

golem::add_(module, fct,...) appends to file if already exists #393

HanjoStudy opened this issue Mar 6, 2020 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@HanjoStudy
Copy link

Calling one of the helper functions to create a module, function or utils golem::add_* when the file already exist appends an empty template to the bottom.

Should probably warn user file already exists.

Quick illustration:

for(i in 1:5){
  golem::add_module( name = "del_module" )
  cat("File size: ", fs::file_info("R/mod_del_module.R")$size, "\n")
}
@ColinFay
Copy link
Member

ColinFay commented Mar 6, 2020

we should skip the writing part if the file already exists, for example at https://github.com/ThinkR-open/golem/blob/dev/R/add_modules.R#L60

@ColinFay ColinFay self-assigned this Mar 6, 2020
@ColinFay ColinFay added the bug Something isn't working label Mar 6, 2020
@ColinFay
Copy link
Member

ColinFay commented May 1, 2020

Happens with :

  • golem::add_rstudioconnect_file()

  • golem::add_shinyappsio_file()

  • golem::add_shinyserver_file()

  • golem::add_js_file()

  • golem::add_js_handler()

  • golem::add_module()

  • golem::add_ui_server_files()

-> Error (should be avoid)

  • golem::use_recommended_tests()

ColinFay added a commit that referenced this issue May 4, 2020
@ColinFay
Copy link
Member

ColinFay commented May 4, 2020

> library(golem)
> for (fun in list(
+   add_rstudioconnect_file,
+   add_shinyappsio_file, 
+   add_shinyserver_file
+ )){
+   for (i in 1:5){
+     fun(open = FALSE)
+     cat("File size: ", fs::file_info("app.R")$size, "\n")
+   }
+ 
+ }
✓ File already exists.Go to /Users/colin/Seafile/documents_colin/R/trash/testGolem/app.R
File size:  302File already exists.Go to /Users/colin/Seafile/documents_colin/R/trash/testGolem/app.R
File size:  302File already exists.Go to /Users/colin/Seafile/documents_colin/R/trash/testGolem/app.R
File size:  302File already exists.Go to /Users/colin/Seafile/documents_colin/R/trash/testGolem/app.R
File size:  302File already exists.Go to /Users/colin/Seafile/documents_colin/R/trash/testGolem/app.R
File size:  302File already exists.Go to /Users/colin/Seafile/documents_colin/R/trash/testGolem/app.R
File size:  302File already exists.Go to /Users/colin/Seafile/documents_colin/R/trash/testGolem/app.R
File size:  302File already exists.Go to /Users/colin/Seafile/documents_colin/R/trash/testGolem/app.R
File size:  302File already exists.Go to /Users/colin/Seafile/documents_colin/R/trash/testGolem/app.R
File size:  302File already exists.Go to /Users/colin/Seafile/documents_colin/R/trash/testGolem/app.R
File size:  302File already exists.Go to /Users/colin/Seafile/documents_colin/R/trash/testGolem/app.R
File size:  302File already exists.Go to /Users/colin/Seafile/documents_colin/R/trash/testGolem/app.R
File size:  302File already exists.Go to /Users/colin/Seafile/documents_colin/R/trash/testGolem/app.R
File size:  302File already exists.Go to /Users/colin/Seafile/documents_colin/R/trash/testGolem/app.R
File size:  302File already exists.Go to /Users/colin/Seafile/documents_colin/R/trash/testGolem/app.R
File size:  302 
> 
> for(i in 1:5){
+   golem::add_module( name = "del_module", open = FALSE)
+   cat("File size: ", fs::file_info("R/mod_del_module.R")$size, "\n")
+ }
✓ File already exists.Go to R/mod_del_module.R
File size:  541File already exists.Go to R/mod_del_module.R
File size:  541File already exists.Go to R/mod_del_module.R
File size:  541File already exists.Go to R/mod_del_module.R
File size:  541File already exists.Go to R/mod_del_module.R
File size:  541 
> 
> 
> for (fun in list(
+   add_js_handler, 
+   add_js_file
+ )){
+   for(i in 1:5){
+     fun("d", open = FALSE)
+     cat("File size: ", 
+         fs::file_info("inst/app/www/d.js")$size, "\n")
+   }
+ }
✓ File already exists.Go to /Users/colin/Seafile/documents_colin/R/trash/testGolem/inst/app/www/d.js
File size:  100File already exists.Go to /Users/colin/Seafile/documents_colin/R/trash/testGolem/inst/app/www/d.js
File size:  100File already exists.Go to /Users/colin/Seafile/documents_colin/R/trash/testGolem/inst/app/www/d.js
File size:  100File already exists.Go to /Users/colin/Seafile/documents_colin/R/trash/testGolem/inst/app/www/d.js
File size:  100File already exists.Go to /Users/colin/Seafile/documents_colin/R/trash/testGolem/inst/app/www/d.js
File size:  100File already exists.Go to /Users/colin/Seafile/documents_colin/R/trash/testGolem/inst/app/www/d.js
File size:  100File already exists.Go to /Users/colin/Seafile/documents_colin/R/trash/testGolem/inst/app/www/d.js
File size:  100File already exists.Go to /Users/colin/Seafile/documents_colin/R/trash/testGolem/inst/app/www/d.js
File size:  100File already exists.Go to /Users/colin/Seafile/documents_colin/R/trash/testGolem/inst/app/www/d.js
File size:  100File already exists.Go to /Users/colin/Seafile/documents_colin/R/trash/testGolem/inst/app/www/d.js
File size:  100 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants