Skip to content

Commit

Permalink
updates get_talkbank_data to suppress messages cross-platform
Browse files Browse the repository at this point in the history
  • Loading branch information
francojc committed Aug 16, 2024
1 parent 16db8fa commit 71a84ee
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions R/get_talkbank_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#' @importFrom fs dir_exists dir_create file_exists path
#' @importFrom R.utils withTimeout
#' @importFrom readr write_csv
#' @import TBDBr
#' @importFrom TBDBr getUtterances getTranscripts getParticipants getTokens
#' @importFrom tidyr unnest
#'
#' @export
Expand Down Expand Up @@ -135,12 +135,26 @@ get_talkbank_data <-
# Helper functions

suppress_output <- function(func, ...) {
sink("/dev/null") # redirect output to null
# Create a text connection to capture output
temp_output <- character()
tc <- textConnection("temp_output", "w", local = TRUE)

# Redirect output to the text connection
sink(tc)
sink(tc, type = "message")

# Run the function and capture the result
result <- tryCatch({
func(...) # run the function
func(...)
}, finally = {
sink(NULL) # restore normal output
# Restore normal output
sink(type = "message")
sink()

# Close the text connection
close(tc)
})

return(result)
}

Expand Down

0 comments on commit 71a84ee

Please sign in to comment.