Merge pull request #1898 from lorenzwalthert/idenfity-package-over-package-field

Use more common package definition for R
This commit is contained in:
Anthony Sottile 2021-05-04 18:59:23 -07:00 committed by GitHub
commit 0107df0a2b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -107,11 +107,13 @@ def install_environment(
'renv::activate("', file.path(getwd()), '"); '
)
writeLines(activate_statement, 'activate.R')
is_package <- tryCatch({{
content_desc <- read.dcf(file.path(prefix_dir, 'DESCRIPTION'))
suppressWarnings(unname(content_desc[,'Type']) == "Package")
}},
error = function(...) FALSE
is_package <- tryCatch(
{{
path_desc <- file.path(prefix_dir, 'DESCRIPTION')
suppressWarnings(desc <- read.dcf(path_desc))
"Package" %in% colnames(desc)
}},
error = function(...) FALSE
)
if (is_package) {{
renv::install(prefix_dir)