From 9983ccc639b37de08ea382270109bf4d6d6f6c3a Mon Sep 17 00:00:00 2001 From: olivroy Date: Wed, 13 Dec 2023 17:39:15 -0500 Subject: [PATCH] Remove crayon dependency and use cli for styling. --- DESCRIPTION | 1 - R/utils.R | 25 +++++++++++-------------- tests/testthat/test-warning.R | 3 +-- 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 57eaa61..73ebdf7 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -21,7 +21,6 @@ Imports: rlang (>= 1.1.0) Suggests: covr, - crayon, knitr, lintr, rmarkdown, diff --git a/R/utils.R b/R/utils.R index fb2494e..dddf250 100644 --- a/R/utils.R +++ b/R/utils.R @@ -11,20 +11,17 @@ paste_line <- function(...) { } # nocov start -has_crayon <- function() { - is_installed("crayon") && crayon::has_color() -} -red <- function(x) if (has_crayon()) crayon::red(x) else x -blue <- function(x) if (has_crayon()) crayon::blue(x) else x -green <- function(x) if (has_crayon()) crayon::green(x) else x -yellow <- function(x) if (has_crayon()) crayon::yellow(x) else x -magenta <- function(x) if (has_crayon()) crayon::magenta(x) else x -cyan <- function(x) if (has_crayon()) crayon::cyan(x) else x -blurred <- function(x) if (has_crayon()) crayon::blurred(x) else x -silver <- function(x) if (has_crayon()) crayon::silver(x) else x -bold <- function(x) if (has_crayon()) crayon::bold(x) else x -italic <- function(x) if (has_crayon()) crayon::italic(x) else x -underline <- function(x) if (has_crayon()) crayon::underline(x) else x +red <- function(x) cli::col_red(x) +blue <- function(x) cli::col_blue(x) +green <- function(x) cli::col_green(x) +yellow <- function(x) cli::col_yellow(x) +magenta <- function(x) cli::col_magenta(x) +cyan <- function(x) cli::col_cyan(x) +blurred <- function(x) cli::style_blurred(x) +silver <- function(x) cli::col_silver(x) +bold <- function(x) cli::style_bold(x) +italic <- function(x) cli::style_italic(x) +underline <- function(x) cli::style_underline(x) # nocov end pkg_url_bug <- function(pkg) { diff --git a/tests/testthat/test-warning.R b/tests/testthat/test-warning.R index 2a4884a..7bf1396 100644 --- a/tests/testthat/test-warning.R +++ b/tests/testthat/test-warning.R @@ -6,8 +6,7 @@ test_that("deprecation warning is displayed with backtrace", { local_options( rlang_trace_top_env = current_env(), - rlang_trace_format_srcrefs = FALSE, - crayon.enabled = FALSE + rlang_trace_format_srcrefs = FALSE ) f <- function() g()