Skip to content

Commit

Permalink
Avoid double printing error message
Browse files Browse the repository at this point in the history
quarto does put everything in stderr so when error we were printing two times.

Let's catch first, and then print non error output if any
  • Loading branch information
cderv committed Jan 31, 2024
1 parent 1cb0f5a commit 8a083a4
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion R/quarto.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ quarto_version <- function() {
#' @importFrom processx run
quarto_run <- function(args = character(), quarto_bin = find_quarto(), echo = FALSE, echo_cmd = getOption("quarto.echo_cmd", FALSE), ..., .call = rlang::caller_env()) {
res <- tryCatch({
processx::run(quarto_bin, args = args, echo = echo, error_on_status = TRUE, echo_cmd = echo_cmd, ...)
processx::run(quarto_bin, args = args, echo = FALSE, error_on_status = TRUE, echo_cmd = echo_cmd, ...)
},
error = function(e) {
msg <- c("Error running quarto cli:")
Expand All @@ -58,6 +58,11 @@ quarto_run <- function(args = character(), quarto_bin = find_quarto(), echo = FA
rlang::abort(msg, call = .call, parent = e)
}
)
# quarto outputs any message into stderr as stdout is reserved
# for regular rendered output (that we don't support in this package yet)
if (echo && nzchar(res$stderr)) {
cli::cat_line(res$stderr)
}
invisible(res)
}

Expand Down

0 comments on commit 8a083a4

Please sign in to comment.