Permalink
Browse files

run_onload: call .onLoad with package name

  • Loading branch information...
1 parent 7825b5d commit 5d97fd02adcc0f4465686fe79d72213683438543 @wch wch committed Dec 15, 2012
Showing with 8 additions and 1 deletion.
  1. +8 −1 R/run-loadhooks.r
View
9 R/run-loadhooks.r
@@ -6,6 +6,13 @@
#'
#' A variable called \code{onLoad} is created in the package's
#' devtools metdata to indicate that it's attached.
+#'
+#' When a package is loaded with \code{library()} it calls
+#' \code{.onLoad(libpath, pkg)}, where \code{libpath} is the library path for
+#' package, and \code{pkg} is the name of the package. Because in-development
+#' packages are not installed to a library, this function can't call
+#' \code{.onLoad} with a proper libpath, so it uses \code{NULL} instead.
+#'
#' @param pkg package description, can be path or package name. See
#' \code{\link{as.package}} for more information
run_onload <- function(pkg = ".") {
@@ -16,7 +23,7 @@ run_onload <- function(pkg = ".") {
# Run .onLoad if it's defined. Set a flag 'onLoad' in the metadata
if (exists(".onLoad", nsenv, inherits = FALSE) &&
is.null(metadata$onLoad)) {
- nsenv$.onLoad()
+ nsenv$.onLoad(NULL, pkg$package)
metadata$onLoad <- TRUE
}
}

0 comments on commit 5d97fd0

Please sign in to comment.