pacman icon indicating copy to clipboard operation
pacman copied to clipboard

Fix warning in `p_install_gh` when installing multiple packages

Open LoHertel opened this issue 6 years ago • 1 comments

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 with parse_git_repo(). (Because p_install_gh() passes a Github path (e.g. 'trinker/pacman') to p_loaded(). p_loaded() always returns FALSE for Github paths.)
  • Update the code of parse_git_repo() in R/utils.R#L194 from the remotes package. It would act as an interface to call either remotes::parse_github_url() or remotes::parse_repo_spec(). The code for parse_git_repo() is taken from remotes/R/parse-git.R#L97. parse_git_repo() depends on viapply(), therefore it is included from remotes/R/utils.R#L8 as well.

LoHertel avatar May 22 '19 08:05 LoHertel

Coverage Status

Coverage remained the same at 0.0% when pulling 44ceb33d9b7c9746f168789022f7b014bfc1a99f on LoHertel:fix-install-gh into fc09ccd2405e539dec575dbdf7832df82082d4e0 on trinker:master.

coveralls avatar May 22 '19 08:05 coveralls