R/dev-use_hex.R

Defines functions dev_use_hex

Documented in dev_use_hex

#' @title
#' Use a hex sticker
#'
#' @description
#' Adds a script in `dev/use_hex.R` that generates a hex sticker based on
#' certain parameters defined inside the script.
#'
#' @param location location of the logo relative to the `inst` directory.
#'                 Defaults to `figures/logo.png`.
#' @param overwrite whether or not to overwrite the script if it already exists.
#'
#' @export
dev_use_hex <- function(location = "figures/logo.png", overwrite = FALSE,
                        envir = parent.frame()) {

    log_info("Ensuring packages are in the package description")
    usethis::use_package("hexSticker")
    usethis::use_package("magrittr")
    usethis::use_package("grid")
    usethis::use_package("png")

    log_info("Copying template")
    dev_copy_template(
        template    = "dev-hex.R",
        destination = here::here("dev", "dev-hex.R"),
        overwrite   = overwrite,
        envir       = envir
    )

    log_success("Template copied!")
    return(invisible(TRUE))

}
tjpalanca/tjutils documentation built on Jan. 20, 2021, 2:01 p.m.