pacman
pacman copied to clipboard
Fix warning in `p_install_gh` when installing multiple packages
This PR addresses the warning message mentioned in #118 when installing multiple packages with p_install_gh().
The code in R/p_install_gh.R#L24 throws a warning message when passing a vector of repository names to the package argument: p_install_gh(c('path/package', 'path2/repo'))
Warning message:
if (p_loaded(char = package)):
the condition has length > 1 and only the first element will be used
I propose the following changes:
- If clause should check for an array of booleans instead of a single boolean.
- Because
p_loaded()is using the package name to check, whether that package is loaded, the package name should be extracted from the Github path beforehand withparse_git_repo(). (Becausep_install_gh()passes a Github path (e.g. 'trinker/pacman') top_loaded().p_loaded()always returnsFALSEfor Github paths.) - Update the code of
parse_git_repo()inR/utils.R#L194from theremotespackage. It would act as an interface to call eitherremotes::parse_github_url()orremotes::parse_repo_spec(). The code forparse_git_repo()is taken fromremotes/R/parse-git.R#L97.parse_git_repo()depends onviapply(), therefore it is included fromremotes/R/utils.R#L8as well.