with_demo_project: Run code in temporary project

View source: R/repo-helper.R

with_demo_projectR Documentation

Run code in temporary project

Description

Run code in temporary project

Usage

with_demo_project(code, dir = NULL, news = TRUE, quiet = FALSE)

local_demo_project(
  dir = NULL,
  news = TRUE,
  quiet = FALSE,
  .local_envir = parent.frame()
)

Arguments

code

Code to run with temporary active project

dir

Directory within which to create the mock package folder.

news

If TRUE, create a NEWS.md file.

quiet

Whether to show messages from usethis

.local_envir

The environment to use for scoping. Defaults to current execution environment.

Value

with_demo_project() returns the result of evaluating code.

local_demo_project() is called for its side effect and returns NULL, invisibly.

Examples

with_demo_project({
  # Add a new R file.
  usethis::use_r("cool-function", open = FALSE)
  # Pretend we added useful code inside it.
  # Track the new R file with Git.
  gert::git_add("R/cool-function.R")
  gert::git_commit("- Add cool function.")
  # Bump version with fledge.
  fledge::bump_version()
})

cynkra/fledge documentation built on April 17, 2025, 3:56 a.m.