Skip to content

Commit

Permalink
chore: add edge case
Browse files Browse the repository at this point in the history
  • Loading branch information
sankhadeepdutta committed Nov 8, 2024
1 parent abd1878 commit 62a031f
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions scripts/add_badges.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}


Expand Down

0 comments on commit 62a031f

Please sign in to comment.