Skip to content

Commit 28ca4f9

Browse files
committed
avoid desc/pkgload dependencies
1 parent 0154df1 commit 28ca4f9

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

DESCRIPTION

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,11 @@ Depends:
3333
R (>= 4.0)
3434
Imports:
3535
cli,
36-
desc,
3736
grDevices,
3837
grid,
3938
gtable (>= 0.1.1),
4039
isoband,
4140
lifecycle (> 1.0.1),
42-
pkgload,
4341
rlang (>= 1.1.0),
4442
scales (>= 1.3.0),
4543
stats,

R/edition.R

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ edition_get <- function(.env = parent.frame(), default = 2024L) {
1717
}
1818

1919
# Try to query package description
20-
desc <- find_description(path = ".", package = pkg)
21-
if (is.null(desc)) {
20+
desc_file <- find_description(path = ".", package = pkg)
21+
if (is.null(desc_file)) {
2222
return(default)
2323
}
2424

2525
# Look up edition from the description
2626
field_name <- "Config/ggplot2/edition"
27-
edition <- as.integer(desc$get_field(field_name, default = default))
27+
edition <- as.integer(read.dcf(desc_file, fields = field_name))
2828

2929
# Cache result
3030
env_bind(ggplot_edition, !!pkg := edition)
@@ -53,13 +53,14 @@ edition_require <- function(edition, what, .env = parent.frame()) {
5353

5454
find_description <- function(path, package = NULL) {
5555
if (!is.null(package)) {
56-
return(desc::desc(package = package))
56+
path <- system.file(package = package, "DESCRIPTION")
5757
} else {
58-
try_fetch(
59-
pkgload::pkg_desc(path),
60-
error = function(e) NULL
61-
)
58+
path <- file.path(path, "DESCRIPTION")
6259
}
60+
if (!file.exists(path)) {
61+
return(NULL)
62+
}
63+
path
6364
}
6465

6566
get_pkg_name <- function(env = parent.frame()) {

0 commit comments

Comments
 (0)