R/utils.R

Defines functions are_local_paths are_github_paths

#' Determine which list components provide GitHub repos
#' @param pkg_location_list A list of package locations.
#' @noRd
are_github_paths <- function(pkg_location_list) {

  seq(pkg_location_list) %>%
    purrr::map_lgl(.f = function(x) {
      inherits(pkg_location_list[[x]], "tbl_df") &&
        all(names(pkg_location_list[[x]]) ==
              c("src", "repo", "url", "pkg_path"))}) %>%
    which()
}

#' Determine which list components refer to local paths
#' @param pkg_location_list A list of package locations.
#' @noRd
are_local_paths <- function(pkg_location_list) {

  seq(pkg_location_list) %>%
    purrr::map_lgl(.f = function(x) {
      inherits(pkg_location_list[[x]], "character") &&
        pkg_location_list[[x]] %>% dir.exists()}) %>%
    which()
}
rich-iannone/pkgattrs documentation built on July 28, 2020, 7:42 p.m.