golem
golem copied to clipboard
Improve `set_golem_name()` if tests or vignettes exists
Actually golem::set_golem_name is not updating golem name in tests/ or vignettes/ if they exists.
It could generate errors when we launch devtools::check()
golem::create_golem("rlop")
golem::fill_desc(
pkg_name = "rlop",
pkg_title = "PKG_TITLE",
pkg_description = "PKG_DESC.",
author_first_name = "AUTHOR_FIRST",
author_last_name = "AUTHOR_LAST",
author_email = "[email protected]",
repo_url = NULL
)
golem::set_golem_options()
usethis::use_mit_license("Golem User")
golem::use_recommended_tests()
usethis::use_vignette("rlop")
devtools::check()
# 0 errors ✓ | 0 warnings ✓ | 0 notes ✓
the tests/testthat.R file looks like this :
library(testthat)
library(rlop)
test_check("rlop")
and vignettes/rlop.Rmd :
---
title: "rlop"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{rplop}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
```
```{r setup}
library(rlop)
```
Then if we change the golem name , we will have several kind of errors :
golem::set_golem_name(name = "plop")
devtools::check()
with vignettes/
E creating vignettes (1.8s)
--- re-building ‘rlop.Rmd’ using rmarkdown
Quitting from lines 18-19 (rlop.Rmd)
Error: processing vignette 'rlop.Rmd' failed with diagnostics:
there is no package called 'rlop'
--- failed re-building ‘rlop.Rmd’
SUMMARY: processing the following file failed:
‘rlop.Rmd’
Error: Vignette re-building failed.
Execution halted
and with tests/
── Test failures ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── testthat ────
> library(testthat)
> library(rlop)
Error in library(rlop) : there is no package called 'rlop'
Execution halted
1 error x | 0 warnings ✓ | 0 notes ✓