Skip to content

Commit

Permalink
replace %||% with custom function.
Browse files Browse the repository at this point in the history
%||% requires 4.4.0 or later.
  • Loading branch information
ThierryO committed May 22, 2024
1 parent 7ba6971 commit 70568a7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
8 changes: 4 additions & 4 deletions .zenodo.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,23 @@
"name": "Onkelinx, Thierry",
"affiliation": "Research Institute for Nature and Forest (INBO)",
"orcid": "0000-0001-8804-4216",
"type": "ContactPerson"
"type": "contactperson"
},
{
"name": "Lommelen, Els",
"affiliation": "Research Institute for Nature and Forest (INBO)",
"orcid": "0000-0002-3481-5684",
"type": "ProjectMember"
"type": "projectmember"
},
{
"name": "Van Calster, Hans",
"affiliation": "Research Institute for Nature and Forest (INBO)",
"orcid": "0000-0001-8595-8426",
"type": "ProjectMember"
"type": "projectmember"
},
{
"name": "Research Institute for Nature and Forest (INBO)",
"type": "RightsHolder"
"type": "rightsholder"
}
],
"creators": [
Expand Down
15 changes: 14 additions & 1 deletion R/upload_zenodo.R
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ zen_upload <- function(zenodo, zen_rec, path) {
msg = ifelse(
zen_rec$status == "400",
"Problem authenticating to Zenodo. Check the Zenodo token.",
zen_rec$message %||% "Error uploading to Zenodo without error message."
first_non_null(
zen_rec$message, "Error uploading to Zenodo without error message."
)
)
)

Expand All @@ -98,3 +100,14 @@ zen_upload <- function(zenodo, zen_rec, path) {
}
return(zen_rec)
}

first_non_null <- function(...) {
dots <- list(...)
if (length(dots) == 0) {
return(NULL)

Check warning on line 107 in R/upload_zenodo.R

View check run for this annotation

Codecov / codecov/patch

R/upload_zenodo.R#L105-L107

Added lines #L105 - L107 were not covered by tests
}
if (!is.null(dots[[1]])) {
return(dots[[1]])

Check warning on line 110 in R/upload_zenodo.R

View check run for this annotation

Codecov / codecov/patch

R/upload_zenodo.R#L109-L110

Added lines #L109 - L110 were not covered by tests
}
do.call(first_non_null, tail(dots, -1))

Check warning on line 112 in R/upload_zenodo.R

View check run for this annotation

Codecov / codecov/patch

R/upload_zenodo.R#L112

Added line #L112 was not covered by tests
}

0 comments on commit 70568a7

Please sign in to comment.