forked from quarto-dev/quarto-r
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinspect.R
51 lines (45 loc) · 1.4 KB
/
inspect.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#' Inspect Quarto Input File or Project
#'
#' Inspect a Quarto project or input path. Inspecting a project returns its
#' config and engines. Inspecting an input path return its formats, engine,
#' and dependent resources.
#'
#' @inheritParams quarto_render
#'
#' @param input The input file or project directory to inspect.
#'
#' @return Named list. For input files, the list contains the elements
#' `quarto`, `engines`, `formats`, `resources`, plus `project` if the file is
#' part of a Quarto project. For projects, the list contains the elements
#' `quarto`, `dir`, `engines`, `config` and `files`.
#'
#' @examples
#' \dontrun{
#' # Inspect input file file
#' quarto_inspect("notebook.Rmd")
#'
#' # Inspect project
#' quarto_inspect("myproject")
#'
#' # Inspect project's advanced profile
#' quarto_inspect(
#' input = "myproject",
#' profile = "advanced"
#' )
#' }
#' @importFrom jsonlite fromJSON
#' @export
quarto_inspect <- function(input = ".",
profile = NULL,
quiet = FALSE,
quarto_args = NULL) {
quarto_bin <- find_quarto()
args <- c("inspect", path.expand(input))
if (!is.null(profile)) {
args <- c(args, c("--profile", paste0(profile, collapse = ",")))
}
if (isTRUE(quiet)) args <- cli_arg_quiet(args)
args <- c(args, quarto_args)
res <- quarto_run(args, quarto_bin = quarto_bin)
fromJSON(res$stdout)
}