R/zzz.R

Defines functions is_package

is_package <- function(path, old_cm){

  # Package structure?
  structure <- all(c("DESCRIPTION", "NAMESPACE", "man", "R") %in%
        dir(path))

  if (structure) {
    return(TRUE) # package if it has the right structure
    } else {
    if (!is.null(old_cm)) {
    if (
      length(old_cm[purrr::map_chr(old_cm, "identifier") ==
      basename(path)]) > 0
    ) {
      return(TRUE) # or if it is already in the registry
      }
    }

    }
  return(FALSE) # not a package in other cases (no old registry, or no entry in it)
}
ropensci-org/makeregistry documentation built on Feb. 12, 2025, 7:33 p.m.