Skip to content
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

Check that the names are unique when passing to file creation. #781

Closed
ColinFay opened this issue Nov 5, 2021 · 2 comments
Closed

Check that the names are unique when passing to file creation. #781

ColinFay opened this issue Nov 5, 2021 · 2 comments

Comments

@ColinFay
Copy link
Member

ColinFay commented Nov 5, 2021

When passing multiple arguments to the functions, the function will fail.

colin:golem colin$ cd /tmp/
colin:tmp colin$ Rscript -e "golem::create_golem('pouet')"
── Checking package name 
✔ Valid package name
── Creating dir 
✔ Created package directory
── Copying package skeleton 
✔ Copied app skeleton
── Setting the default config 
✔ Configured app
── Running project hook function 
✔ All set
✔ Setting active project to '/private/tmp/pouet'
── Done 
A new golem named pouet was created at /private/tmp/pouet .
To continue working on your app, start editing the 01_start.R file.
colin:tmp colin$ cd pouet/
colin:pouet colin$ Rscript -e "golem::add_module(c('plif', 'plouf'))"
Error in file(file, ifelse(append, "a", "w")) : 
  invalid 'description' argument
Calls: <Anonymous> ... module_template -> write_there -> write -> cat -> file
In addition: Warning messages:
1: In if (!file_exists(where)) { :
  the condition has length > 1 and only the first element will be used
2: In if (file == "") file <- stdout() else if (startsWith(file, "|")) { :
  the condition has length > 1 and only the first element will be used
3: In if (startsWith(file, "|")) { :
  the condition has length > 1 and only the first element will be used
Execution halted
colin:pouet colin$ ls
DESCRIPTION     NAMESPACE       R               dev             inst            man
colin:pouet colin$ Rscript -e "golem::add_module(c('plif'))"
✔ File already exists.
• Go to R/mod_plif.R

Should these functions:

  • Take only the first value of the vector or
  • Fail gracefully
@ColinFay
Copy link
Member Author

ColinFay commented Nov 5, 2021

I think we should fail gracefully.

attempt::stop_if(name, ~ length(.x) > 1, "Name should be of length 1")

@ColinFay
Copy link
Member Author

ColinFay commented Nov 5, 2021

Other idea, vectorized versions :

golem::add_modules()
golem::add_css_files()
etc.

ColinFay added a commit that referenced this issue Aug 18, 2022
Functions that add or use files can no
longer take an argument name of
length() > 1

close #781
ColinFay added a commit that referenced this issue Aug 19, 2022
Functions that add or use files can no
longer take an argument name of
length() > 1

close #781
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant