Skip to content

Commit c651265

Browse files
committed
tweak quarto_list_extensions()
1 parent ba02f7b commit c651265

File tree

6 files changed

+34
-20
lines changed

6 files changed

+34
-20
lines changed

NAMESPACE

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,4 @@ importFrom(rstudioapi,isAvailable)
4141
importFrom(rstudioapi,viewer)
4242
importFrom(tools,vignetteEngine)
4343
importFrom(utils,browseURL)
44-
importFrom(utils,read.table)
4544
importFrom(yaml,write_yaml)

NEWS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# quarto (development version)
22

3+
- Add several new wrapper function:
4+
- `quarto_list_extensions()` to list installed extensions using `quarto list extensions`
5+
36
- `quarto_preview()` gains a `quiet` argument to suppress any output from R or Quarto CLI (thanks, @cwickham, #232.)
47

58
- Add some helpers function `theme_brand_*` and `theme_colors_*` to help theme with dark and light brand using some common graph and table packages (thanks, @gordonwoodhull, [#234](https://github.com/quarto-dev/quarto-r/issues/234)).

R/list.R

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,33 @@
22
#'
33
#' List Quarto Extensions in this folder or project by running `quarto list`
44
#'
5-
#' @inheritParams quarto_render
5+
#' @return A data frame with the installed extensions or NULL (invisibly) if no extensions are installed.
66
#'
77
#' @examples
88
#' \dontrun{
99
#' # List Quarto Extensions in this folder or project
1010
#' quarto_list_extensions()
1111
#' }
1212
#'
13-
#' @importFrom rlang is_interactive
14-
#' @importFrom cli cli_abort
15-
#' @importFrom utils read.table
1613
#' @export
17-
quarto_list_extensions <- function(quiet = FALSE, quarto_args = NULL) {
14+
quarto_list_extensions <- function() {
1815
quarto_bin <- find_quarto()
1916

20-
args <- c("extensions", if (quiet) cli_arg_quiet(), quarto_args)
21-
x <- quarto_list(args, quarto_bin = quarto_bin, echo = TRUE)
17+
# quarto list extensions --quiet will return nothing so we need to prevent that.
18+
args <- c("extensions")
19+
x <- quarto_list(args, quarto_bin = quarto_bin, echo = FALSE)
2220
# Clean the stderr output to remove extra spaces and ensure consistent formatting
2321
stderr_cleaned <- gsub("\\s+$", "", x$stderr)
2422
if (grepl("No extensions are installed", stderr_cleaned)) {
2523
invisible()
2624
} else {
27-
invisible(utils::read.table(
25+
utils::read.table(
2826
text = stderr_cleaned,
2927
header = TRUE,
3028
fill = TRUE,
3129
sep = "",
3230
stringsAsFactors = FALSE
33-
))
31+
)
3432
}
3533
}
3634

man/quarto_list_extensions.Rd

Lines changed: 3 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/_snaps/list.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Listing extensions
2+
3+
Code
4+
quarto_list_extensions()
5+
Output
6+
Id Version Contributes
7+
1 quarto-ext/fontawesome 1.2.0 shortcodes
8+
9+
---
10+
11+
Code
12+
quarto_list_extensions()
13+
Output
14+
Id Version Contributes
15+
1 quarto-ext/fontawesome 1.2.0 shortcodes
16+
2 quarto-ext/lightbox 0.1.9 filters
17+

tests/testthat/test-list.R

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
test_that("Listing extensions", {
2+
# don't try to install extensions on CRAN
3+
skip_on_cran()
24
skip_if_no_quarto()
35
skip_if_offline("github.com")
46
qmd <- local_qmd_file(c("content"))
57
withr::local_dir(dirname(qmd))
68
expect_null(quarto_list_extensions())
79
quarto_add_extension("quarto-ext/fontawesome", no_prompt = TRUE, quiet = TRUE)
810
expect_true(dir.exists("_extensions/quarto-ext/fontawesome"))
9-
expect_equal(nrow(quarto_list_extensions()), 1)
11+
expect_snapshot(quarto_list_extensions())
1012
quarto_add_extension("quarto-ext/lightbox", no_prompt = TRUE, quiet = TRUE)
1113
expect_true(dir.exists("_extensions/quarto-ext/lightbox"))
12-
expect_equal(nrow(quarto_list_extensions()), 2)
14+
expect_snapshot(quarto_list_extensions())
1315
})

0 commit comments

Comments
 (0)