create_compendium("pkgname") doesn't check whether "pkgname" already exists
soniamitchell opened this issue · 3 comments
soniamitchell commented
Describe the bug
The function create_compendium("pkgname") doesn't check whether "pkgname" already exists. If pkgname is a folder, the package is merged with an existing folder. If pkgname is a file, an error occurs.
To Reproduce
- In terminal, create file '~/Desktop/pkgname'
> create_compendium('pkgname')
Error in writeLines(c("cat(crayon::bold('\nThis project was set up by rrtools.\n'))", :
cannot open the connection
In addition: Warning messages:
1: In dir.create(path) : 'pkgname' already exists
2: In writeLines(c("cat(crayon::bold('\nThis project was set up by rrtools.\n'))", :
cannot open file 'pkgname/.Rprofile': Not a directory
>
Expected behavior
Check whether 'pkgname' already exists and if it does, stop.
benmarwick commented
Thanks, that does seem like something we could handle more gracefully. Do you have something in mind for a fix? Is there another package that does this very well which we can look at for inspiration?
soniamitchell commented
Maybe something like this:
if (!dir.exists(path)){
dir.create(path)
} else {
print("Directory already exists!")
}
at line 89 in core_use_compendium.R ?
benmarwick commented
Thank you, would you like to make a pull request (with a test) to add this?