Skip to content

Commit

Permalink
properly nullify empty string with rlang
Browse files Browse the repository at this point in the history
  • Loading branch information
kbvernon committed Nov 21, 2023
1 parent 8088490 commit 6c1a396
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion R/create_extendr_package.R
Original file line number Diff line number Diff line change
Expand Up @@ -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

Check warning on line 27 in R/create_extendr_package.R

View check run for this annotation

Codecov / codecov/patch

R/create_extendr_package.R#L26-L27

Added lines #L26 - L27 were not covered by tests
}

args <- purrr::map(args, nullify_empty_string)

Check warning on line 30 in R/create_extendr_package.R

View check run for this annotation

Codecov / codecov/patch

R/create_extendr_package.R#L30

Added line #L30 was not covered by tests

# build package directory, but don't open yet!
usethis::create_package(
Expand Down

0 comments on commit 6c1a396

Please sign in to comment.