From 4ba5f3e93654481059f467883f64e7dd3725cca7 Mon Sep 17 00:00:00 2001 From: Nicolas Casajus Date: Tue, 24 Sep 2024 09:42:23 +0200 Subject: [PATCH] fix: store sticker in figures/readme - fix #62 --- R/utils-io.R | 23 ++++++++++++++++++----- inst/templates/README-comp.Rmd | 4 ++-- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/R/utils-io.R b/R/utils-io.R index bfc3633..0147368 100644 --- a/R/utils-io.R +++ b/R/utils-io.R @@ -171,17 +171,30 @@ add_sticker <- function(type, overwrite = FALSE, quiet = FALSE) { stop_if_not_logical(overwrite, quiet) - path <- file.path(path_proj(), "man", "figures", paste0(type, "-sticker.png")) + if (type == "package") { + + path <- file.path(path_proj(), "man", "figures", + paste0(type, "-sticker.png")) + + pathdir <- file.path("man", "figures") + + } else { + + path <- file.path(path_proj(), "figures", "readme", + paste0(type, "-sticker.png")) + + pathdir <- file.path("figures", "readme") + } if (file.exists(path) && !overwrite) { - stop(paste0("A 'man/figures/", type, "-sticker.png' is already present. ", - "If you want to replace it, please use `overwrite = TRUE`.")) + stop(paste0("A '", pathdir, "/", type, "-sticker.png' is already present. ", + "If you want to replace it, please use `overwrite = TRUE`.")) } - if (!dir.exists(file.path(path_proj(), "man", "figures"))) - dir.create(file.path(path_proj(), "man", "figures"), showWarnings = FALSE, + if (!dir.exists(file.path(path_proj(), pathdir))) + dir.create(file.path(path_proj(), pathdir), showWarnings = FALSE, recursive = TRUE) invisible( diff --git a/inst/templates/README-comp.Rmd b/inst/templates/README-comp.Rmd index b2eedb8..485a3f9 100644 --- a/inst/templates/README-comp.Rmd +++ b/inst/templates/README-comp.Rmd @@ -8,13 +8,13 @@ output: github_document ```{r, include = FALSE} knitr::opts_chunk$set(collapse = TRUE, comment = "#>", - fig.path = "man/figures/", + fig.path = "figures/readme/", out.width = "100%") ``` -{{project_name}} +{{project_name}} =========================================================