Skip to contents

If pkg is not provided, the package name is based on the basename of the project working directory. By default, the package is created in a temporary directory and deleted when the session restarts.

Usage

create_temp_package(
  path,
  pkg = NULL,
  fields = list(),
  rstudio = FALSE,
  check_name = TRUE,
  open = FALSE,
  tmp_dir = tempdir(),
  overwrite = FALSE,
  call = caller_env()
)

Arguments

path

A character vector of one or more paths.

pkg

Package name. Optional.

fields

A named list of fields to add to DESCRIPTION, potentially overriding default values. See use_description() for how you can set personalized defaults using package options.

rstudio

If TRUE, calls use_rstudio() to make the new package or project into an RStudio Project. If FALSE and a non-package project, a sentinel .here file is placed so that the directory can be recognized as a project by the here or rprojroot packages.

check_name

Whether to check if the name is valid for CRAN and throw an error if not.

open

If TRUE, activates the new project:

  • If using RStudio desktop, the package is opened in a new session.

  • If on RStudio server, the current RStudio project is activated.

  • Otherwise, the working directory and active project is changed.

tmp_dir

Directory where temporary package is created. Defaults to tempdir().

overwrite

Default FALSE. If TRUE, overwrite the NAMESPACE file and any R scripts at the same location sharing the same names.

call

The execution environment of a currently running function, e.g. caller_env(). The function will be mentioned in error messages as the source of the error. See the call argument of abort() for more information.

Value

Invisibly returns path to the package location