Skip to contents

Temporarily create a rdev or R analysis package, which is automatically removed afterwards.

Usage

local_temppkg(dir = fs::file_temp(), type = "usethis", env = parent.frame())

Arguments

dir

Path to package directory, created if necessary, defaults to fs::file_temp().

type

type of package to create, one of "usethis" - usethis::create_package(), "rdev" - use_rdev_package(), "analysis" - use_analysis_package(use_quarto = FALSE), or "quarto" - use_analysis_package(use_quarto = TRUE).

env

Environment passed to withr::defer(), defaults to parent.frame().

Value

Path to temporary package directory.

Details

Used internally for testing rdev automation. Based on the usethis case study from testthat.

Examples

if (FALSE) {
test_that("local_temppkg creates a directory", {
  dir <- usethis::ui_silence(local_temppkg())
  expect_true(fs::dir_exists(dir))
})
}