Skip to content

Commit 050a590

Browse files
committed
new air adds brackets for inline condition
1 parent 9901418 commit 050a590

File tree

6 files changed

+33
-12
lines changed

6 files changed

+33
-12
lines changed

R/inspect.R

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ quarto_inspect <- function(
4343
args <- c(args, c("--profile", paste0(profile, collapse = ",")))
4444
}
4545

46-
if (is_quiet(quiet)) args <- cli_arg_quiet(args)
46+
if (is_quiet(quiet)) {
47+
args <- cli_arg_quiet(args)
48+
}
4749

4850
args <- c(args, quarto_args)
4951

R/quarto-args.R

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ is_quiet <- function(quiet) {
1313
}
1414
# these option takes precedence
1515
quiet_options <- getOption("quarto.quiet", Sys.getenv("QUARTO_R_QUIET", NA))
16-
if (!is.na(quiet_options)) return(isTRUE(as.logical(quiet_options)))
16+
if (!is.na(quiet_options)) {
17+
return(isTRUE(as.logical(quiet_options)))
18+
}
1719
isTRUE(quiet)
1820
}
1921

R/quarto.R

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,12 @@ quarto_available <- function(min = NULL, max = NULL, error = FALSE) {
9797
error = function(e) NULL
9898
)
9999
if (!is.null(quarto_version)) {
100-
if (!is.null(min)) is_above <- quarto_version >= min
101-
if (!is.null(max)) is_below <- quarto_version <= max
100+
if (!is.null(min)) {
101+
is_above <- quarto_version >= min
102+
}
103+
if (!is.null(max)) {
104+
is_below <- quarto_version <= max
105+
}
102106
found <- is_above && is_below
103107
}
104108
if (!found && error) {
@@ -168,11 +172,12 @@ quarto_run <- function(
168172

169173
# if `--quiet` has been set, quarto CLI won't report any error (e$stderr will be empty)
170174
# So remind user to run without `--quiet` to see the full error message
171-
if (cli_arg_quiet() %in% args)
175+
if (cli_arg_quiet() %in% args) {
172176
msg <- c(
173177
msg,
174178
"i" = "Rerun with `quiet = FALSE` to see the full error message."
175179
)
180+
}
176181

177182
cli::cli_abort(msg, call = .call, parent = e)
178183
}
@@ -223,16 +228,20 @@ is_using_quarto <- function(dir = ".", verbose = FALSE) {
223228
0
224229
has_qmd <- length(list.files(dir, pattern = "\\.qmd$", full.names = TRUE)) > 0
225230
if (has_quarto_yml) {
226-
if (verbose) cli::cli_inform("A {.file _quarto.yml} has been found.")
231+
if (verbose) {
232+
cli::cli_inform("A {.file _quarto.yml} has been found.")
233+
}
227234
return(TRUE)
228235
} else if (has_qmd) {
229-
if (verbose)
236+
if (verbose) {
230237
cli::cli_inform("At least one file {.code *.qmd} has been found.")
238+
}
231239
return(TRUE)
232240
}
233241
# not a directory using Quarto
234-
if (verbose)
242+
if (verbose) {
235243
cli::cli_inform("No {.file _quarto.yml} or {.code *.qmd} has been found.")
244+
}
236245
return(FALSE)
237246
}
238247

@@ -274,7 +283,9 @@ quarto_binary_sitrep <- function(verbose = TRUE, debug = FALSE) {
274283
quarto_found <- normalizePath(quarto_found, mustWork = FALSE)
275284

276285
same_config <- TRUE
277-
if (debug) verbose <- TRUE
286+
if (debug) {
287+
verbose <- TRUE
288+
}
278289

279290
# Quarto R package situation ----
280291
if (verbose) {

R/utils-prompt.R

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ check_approval <- function(
77
interactive_info = NULL, # could use `{ what }` as used in `cli_inform()`
88
.call = rlang::caller_env()
99
) {
10-
if (no_prompt) return(TRUE)
10+
if (no_prompt) {
11+
return(TRUE)
12+
}
1113

1214
if (!is_interactive()) {
1315
cli::cli_abort(

tests/testthat/helper.R

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,11 @@ transform_quarto_cli_in_output <- function(
172172
if (length(at_lines_after_stack) > 0) {
173173
# Find the continuous sequence (no gaps)
174174
gaps <- diff(at_lines_after_stack) > 1
175-
end_pos <- if (any(gaps)) which(gaps)[1] else
175+
end_pos <- if (any(gaps)) {
176+
which(gaps)[1]
177+
} else {
176178
length(at_lines_after_stack)
179+
}
177180
consecutive_indices <- at_lines_after_stack[1:end_pos]
178181

179182
stack_line <- lines[stack_trace_index]

tests/testthat/test-quarto.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,9 @@ test_that("quarto CLI sitrep", {
6969
list(QUARTO_PATH = dummy_quarto_path, RSTUDIO_QUARTO = NA),
7070
expect_snapshot(
7171
quarto_binary_sitrep(debug = TRUE),
72-
transform = function(lines)
72+
transform = function(lines) {
7373
gsub(dummy_quarto_path, "<QUARTO_PATH path>", lines, fixed = TRUE)
74+
}
7475
)
7576
)
7677
withr::with_envvar(

0 commit comments

Comments
 (0)