From 62a031fd0fe77a26879c5d8d649a74be22fd8dfd Mon Sep 17 00:00:00 2001 From: Sankhadeep Dutta Date: Fri, 8 Nov 2024 19:36:44 +0530 Subject: [PATCH] chore: add edge case --- scripts/add_badges.R | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/scripts/add_badges.R b/scripts/add_badges.R index 3857ea4..e3261d4 100644 --- a/scripts/add_badges.R +++ b/scripts/add_badges.R @@ -21,17 +21,21 @@ write_badge <- function(badge, file, text) { # Load the YAML file yaml_data <- yaml::read_yaml(file) - # Check if the key is available - if (text %in% names(yaml_data)) { - # Update the value - yaml_data[[text]] <- badge - } else { - # Append the new key-value pair - yaml_data[[text]] <- badge + badge <- badge[1] #edge case issue - not a good hack + if(is.na(badge)) return() + if (!rlang::is_empty(badge) & !is.na(badge) & badge != "" & badge != "NA") { + # Check if the key is available + if (text %in% names(yaml_data)) { + # Update the value + yaml_data[[text]] <- badge + } else { + # Append the new key-value pair + yaml_data[[text]] <- badge + } + + # Write the updated YAML data back to the file + yaml::write_yaml(yaml_data, file) } - - # Write the updated YAML data back to the file - yaml::write_yaml(yaml_data, file) }