From 6c1a396092483ac14dd5f37d4f30100fc7a6ebc7 Mon Sep 17 00:00:00 2001 From: kbvernon Date: Tue, 21 Nov 2023 09:03:40 -0700 Subject: [PATCH] properly nullify empty string with `rlang` --- R/create_extendr_package.R | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/R/create_extendr_package.R b/R/create_extendr_package.R index 26744219..878b1d81 100644 --- a/R/create_extendr_package.R +++ b/R/create_extendr_package.R @@ -23,7 +23,11 @@ create_extendr_package <- function(path, ...) { # hunch is that rstudio project text input widgets return empty strings # when no value is given, want to make sure it is NULL so `use_extendr()` # handles it correctly - args <- lapply(args, function(x) if (x == "") return(NULL) else return(x)) + nullify_empty_string <- function(x) { + if (rlang::is_string(x) && nzchar(x)) x else NULL + } + + args <- purrr::map(args, nullify_empty_string) # build package directory, but don't open yet! usethis::create_package(