Skip to content

Commit

Permalink
fix bug in .pal_init() with default role
Browse files Browse the repository at this point in the history
  • Loading branch information
simonpcouch committed Nov 7, 2024
1 parent cf6d469 commit 0e30603
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion R/init-pal.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
...,
.ns = "elmer"
) {
check_role(role)
check_role(role, allow_default = TRUE)
if (!role %in% list_pals()) {
cli::cli_abort(c(
"No pals with role {.arg {role}} registered.",
Expand Down
6 changes: 4 additions & 2 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ list_pals <- function() {
}

# ad-hoc check helpers -------
check_role <- function(role, call = caller_env()) {
check_role <- function(role,
allow_default = !is.null(getOption(".pal_on_load")),
call = caller_env()) {
check_string(role, allow_empty = FALSE, call = call)

if (!is_valid_role(role)) {
Expand All @@ -42,7 +44,7 @@ check_role <- function(role, call = caller_env()) {
)
}

if (role %in% default_roles & is.null(getOption(".pal_on_load"))) {
if (role %in% default_roles & !allow_default) {
cli::cli_abort(
"Default roles cannot be edited or removed.",
call = call
Expand Down

0 comments on commit 0e30603

Please sign in to comment.