Skip to content

Commit

Permalink
Use cli::is_dynamic_tty() do decide on dynamic output
Browse files Browse the repository at this point in the history
This can be forced or suppressed with the `cli.dynamic`
option and the `R_CLI_DYNAMIC` env var. See
`?cli::is_dynamic_tty` for details.

Now pkgbuild output looks OK in Rmds, by default.

Closes #64.
  • Loading branch information
gaborcsardi committed Dec 8, 2021
1 parent 910a5ce commit 9886aee
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
7 changes: 7 additions & 0 deletions R/callback.R
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,10 @@ block_callback <- function(quiet) {
is_new_check <- function(x) {
grepl("^\\* ", x)
}

simple_callback <- function(quiet) {
function(x) {
if (quiet) return()
cat(x)
}
}
8 changes: 7 additions & 1 deletion R/rcmd.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,15 @@ rcmd_build_tools <- function(..., env = character(), required = TRUE, quiet = FA

warn_for_potential_errors()

callback <- if (cli::is_dynamic_tty()) {
block_callback(quiet)
} else {
simple_callback(quiet)
}

res <- with_build_tools(
callr::rcmd_safe(..., env = env, spinner = FALSE, show = FALSE,
echo = FALSE, block_callback = block_callback(quiet), stderr = "2>&1"),
echo = FALSE, block_callback = callback, stderr = "2>&1"),
required = required
)

Expand Down

0 comments on commit 9886aee

Please # to comment.