Skip to content

Commit 1dc2f57

Browse files
committed
utility to manage lifecycles
1 parent 7a746b2 commit 1dc2f57

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

R/utilities.R

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,26 @@ as_cli <- function(..., env = caller_env()) {
784784
cli::cli_fmt(cli::cli_text(..., .envir = env))
785785
}
786786

787+
deprecate <- function(when, ..., id = NULL, always = FALSE, user_env = NULL,
788+
escalate = FALSE) {
789+
790+
defunct <- "3.0.0"
791+
full <- "3.4.0"
792+
soft <- packageVersion("ggplot2")
793+
794+
version <- as.package_version(when)
795+
if (version < defunct) {
796+
lifecycle::deprecate_stop(when, ...)
797+
}
798+
user_env <- user_env %||% getOption("ggplot2_plot_env") %||% caller_env(2)
799+
if (version <= full) {
800+
lifecycle::deprecate_warn(when, ..., id = id, always = always, user_env = user_env)
801+
} else if (version <= soft) {
802+
lifecycle::deprecate_soft(when, ..., id = id, user_env = user_env)
803+
}
804+
invisible()
805+
}
806+
787807
deprecate_soft0 <- function(..., user_env = NULL) {
788808
user_env <- user_env %||% getOption("ggplot2_plot_env") %||% caller_env(2)
789809
lifecycle::deprecate_soft(..., user_env = user_env)

0 commit comments

Comments
 (0)