summaryrefslogtreecommitdiffstats
path: root/pre_commit/languages
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2021-03-12 21:22:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2021-03-12 21:22:14 +0000
commit6d603dbc3e3dcefb210555a8ca54575b96cb0bb2 (patch)
tree4f71f128ada28cb7197ee70479b585a984a49681 /pre_commit/languages
parentReleasing debian version 2.11.0-1. (diff)
downloadpre-commit-6d603dbc3e3dcefb210555a8ca54575b96cb0bb2.tar.xz
pre-commit-6d603dbc3e3dcefb210555a8ca54575b96cb0bb2.zip
Merging upstream version 2.11.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'pre_commit/languages')
-rw-r--r--pre_commit/languages/r.py20
1 files changed, 9 insertions, 11 deletions
diff --git a/pre_commit/languages/r.py b/pre_commit/languages/r.py
index 1d42fea..83e6000 100644
--- a/pre_commit/languages/r.py
+++ b/pre_commit/languages/r.py
@@ -88,13 +88,11 @@ def install_environment(
env_dir = _get_env_dir(prefix, version)
with clean_path_on_failure(env_dir):
os.makedirs(env_dir, exist_ok=True)
- path_desc_source = prefix.path('DESCRIPTION')
- if os.path.exists(path_desc_source):
- shutil.copy(path_desc_source, env_dir)
shutil.copy(prefix.path('renv.lock'), env_dir)
cmd_output_b(
'Rscript', '--vanilla', '-e',
- """\
+ f"""\
+ prefix_dir <- {prefix.prefix_dir!r}
missing_pkgs <- setdiff(
"renv", unname(installed.packages()[, "Package"])
)
@@ -109,15 +107,15 @@ def install_environment(
'renv::activate("', file.path(getwd()), '"); '
)
writeLines(activate_statement, 'activate.R')
- is_package <- tryCatch(
- suppressWarnings(
- unname(read.dcf('DESCRIPTION')[,'Type'] == "Package")
- ),
+ is_package <- tryCatch({{
+ content_desc <- read.dcf(file.path(prefix_dir, 'DESCRIPTION'))
+ suppressWarnings(unname(content_desc[,'Type']) == "Package")
+ }},
error = function(...) FALSE
)
- if (is_package) {
- renv::install(normalizePath('.'))
- }
+ if (is_package) {{
+ renv::install(prefix_dir)
+ }}
""",
cwd=env_dir,
)