sourcePackageToList(pkgDir) listToSourcePackage(List, parentDir = tempfile(fileext = ".dir"))
pkgDir | The name of a directory containing the files comprising a source package. We expect pkgDir to contain files called "DESCRIPTION" and "NAMESPACE" it typically will have directories such as "R", "data", and "src". |
List | A named list of NULLs and character vectors. The names represent file paths and should all start with the name of the package. NULL entries represent directories and character entries are the contents of the non-directory files. sourcePackageToList produces such a list from a source package and listToSourcePackage uses such a list to produce a source package. |
L1 <- list( "pkg/DESCRIPTION" = c("Package: pkg", "Version: 0.1", "Title: A Package", "Description: A demonstration of listToSourcePackage"), "pkg/NAMESPACE" = c("export(increment)"), "pkg/R" = NULL, # a directory "pkg/R/increment.R" = c("increment <- function(x) x + 1")) dir <- assertionTest::listToSourcePackage(L1) dir.create(tlib <- tempfile()) install.packages(repos=NULL, file.path(dir, "pkg"), type = "source", INSTALL_opts = "--no-help", lib=tlib) loadNamespace("pkg", lib=tlib) all.equal( pkg::increment(c(2,3,5)), c(3,4,6) )L2 <- sourcePackageToList(file.path(dir, "pkg")) all.equal(L1, L2)