From e9cdf2c4fb2d271fec22e959cfc6291055ba27e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Cs=C3=A1rdi?= Date: Sun, 10 Dec 2023 14:04:40 +0100 Subject: [PATCH] Update find_package_root() from desc Now we also check for '^Package: ` in the `DESCRIPTION` file. This is the previous behavior with rprojroot. --- R/find-package-root.R | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/R/find-package-root.R b/R/find-package-root.R index 0add54e..40730b2 100644 --- a/R/find-package-root.R +++ b/R/find-package-root.R @@ -17,7 +17,9 @@ find_package_root <- function(path = ".") { ) max_depth <- 100 for (i in 1:max_depth) { - if (file.exists(file.path(cur_path, "DESCRIPTION"))) { + dsc_path <- file.path(cur_path, "DESCRIPTION") + if (file.exists(dsc_path) && + any(grepl("^Package: ", readLines(dsc_path)))) { return(cur_path) } else if (is_root(cur_path)) { stop(errmsg)