Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions inst/scripts/session-start.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,22 @@ load_saber_fun <- function(name, repo_root = NULL) {
if (!is.null(repo_root)) {
local_fun <- tryCatch(
{
desc <- file.path(repo_root, "DESCRIPTION")
r_dir <- file.path(repo_root, "R")
if (!file.exists(file.path(repo_root, "DESCRIPTION")) ||
!dir.exists(r_dir)) {
if (!file.exists(desc) || !dir.exists(r_dir)) {
stop("No local package source found")
}
# Only source from the local repo when it IS
# saber. Other packages may export a symbol
# with the same name (e.g. cerebro::briefing)
# but a different signature.
pkg <- tryCatch(
read.dcf(desc, fields = "Package")[1L, "Package"],
error = function(e) NA_character_
)
if (is.na(pkg) || pkg != "saber") {
stop("Local package is not saber")
}

env <- new.env(parent = baseenv())
r_files <- list.files(r_dir, pattern = "\\.[Rr]$",
Expand Down