Skip to content

Commit

Permalink
Assign .Depends from namespace to package environment to more closely…
Browse files Browse the repository at this point in the history
… simulate library()
  • Loading branch information
yiufung committed Jan 6, 2018
1 parent 70eaef8 commit fe191f2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions R/load.r
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,9 @@ load_all <- function(path = ".", reset = TRUE, recompile = FALSE,
# Copy over objects from the namespace environment
export_ns(package)

# Assign .Depends, if any, to package environment from namespace
assign_depends(package)

# Run hooks
run_pkg_hook(package, "attach")
run_user_hook(package, "attach")
Expand Down
9 changes: 9 additions & 0 deletions R/package-env.r
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ export_ns <- function(package) {
}
}

# Assign `.Depends` from namespace
assign_depends <- function(package) {
pkgenv <- pkg_env(package)

desc <- pkg_desc(ns_path(package))
deps <- desc$get_deps()
depends <- unique(deps[deps$type == "Depends",]$package)
if (length(depends) > 0L) pkgenv$.Depends <- depends
}

#' Return package environment
#'
Expand Down

0 comments on commit fe191f2

Please sign in to comment.