diff --git a/R/type-deps.R b/R/type-deps.R index 8f63efbe..45810bb5 100644 --- a/R/type-deps.R +++ b/R/type-deps.R @@ -14,8 +14,13 @@ parse_remote_deps <- function(specs, config, ...) { resolve_remote_deps <- function(remote, direct, config, cache, dependencies, ...) { - ret <- resolve_remote_local(remote, direct, config, cache, - dependencies, ...) + if (file.exists(file.path(remote$path, "DESCRIPTION"))) { + ret <- resolve_remote_local(remote, direct, config, cache, + dependencies, ...) + } else { + ret <- resolve_remote_local_autodeps(remote, direct, config, cache, + dependencies, ...) + } # We need to do some extra work for the case when a dependency # depends on the ref itself. E.g. when in pak::local_install_dev_deps() @@ -54,6 +59,28 @@ resolve_remote_deps <- function(remote, direct, config, cache, ret2 } +resolve_remote_local_autodeps <- function(remote, direct, config, cache, + dependencies, ...) { + deps <- scan_deps(remote$path) + tmpdesc <- tempfile() + on.exit(unlink(tmpdesc), add = TRUE) + dsc <- desc::desc("!new") + hard <- deps$package[deps$type == "prod"] + soft <- deps$package[deps$type != "prod"] + for (p in hard) dsc$set_dep(p, type = "Depends") + for (s in soft) dsc$set_dep(p, type = "Suggests") + dsc$write(tmpdesc) + resolve_from_description( + tmpdesc, + paste0("file://", normalizePath(tmpdesc)), + remote, + direct, + config, + cache, + dependencies[[2 - direct]] + ) +} + download_remote_deps <- function(resolution, target, target_tree, config, cache, which, on_progress) { ## Nothing to do here