-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace path specification (needed for historical reasons) with `TRUE`/`FALSE`/`NA`. Fixes #658
- Loading branch information
Showing
14 changed files
with
320 additions
and
302 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
inferQuartoInfo <- function(metadata, appDir, appPrimaryDoc) { | ||
if (hasQuartoMetadata(metadata)) { | ||
return(list( | ||
version = metadata[["quarto_version"]], | ||
engines = metadata[["quarto_engines"]] | ||
)) | ||
} | ||
|
||
# If we don't yet have Quarto details, run quarto inspect ourselves | ||
inspect <- quartoInspect( | ||
appDir = appDir, | ||
appPrimaryDoc = appPrimaryDoc | ||
) | ||
if (is.null(inspect)) { | ||
return(NULL) | ||
} | ||
|
||
list( | ||
version = inspect[["quarto"]][["version"]], | ||
engines = I(inspect[["engines"]]) | ||
) | ||
} | ||
|
||
hasQuartoMetadata <- function(x) { | ||
!is.null(x$quarto_version) | ||
} | ||
|
||
# Run "quarto inspect" on the target and returns its output as a parsed object. | ||
quartoInspect <- function(appDir = NULL, appPrimaryDoc = NULL) { | ||
# If "quarto inspect appDir" fails, we will try "quarto inspect | ||
# appPrimaryDoc", so that we can support single files as well as projects. | ||
quarto <- quarto_path() | ||
if (is.null(quarto)) { | ||
cli::cli_abort(c( | ||
"`quarto` not found.", | ||
i = "Check that it is installed and available on your {.envvar PATH}." | ||
)) | ||
} | ||
|
||
paths <- c(appDir, file.path(appDir, appPrimaryDoc)) | ||
|
||
for (path in paths) { | ||
args <- c("inspect", path.expand(path)) | ||
inspect <- tryCatch( | ||
{ | ||
json <- suppressWarnings(system2(quarto, args, stdout = TRUE, stderr = TRUE)) | ||
parsed <- jsonlite::fromJSON(json) | ||
return(parsed) | ||
}, | ||
error = function(e) NULL | ||
) | ||
} | ||
return(NULL) | ||
} | ||
|
||
# inlined from quarto::quarto_path() | ||
quarto_path <- function() { | ||
path_env <- Sys.getenv("QUARTO_PATH", unset = NA) | ||
if (is.na(path_env)) { | ||
path <- unname(Sys.which("quarto")) | ||
if (nzchar(path)) { | ||
path | ||
} else { | ||
NULL | ||
} | ||
} else { | ||
path_env | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# quartoInspect requires quarto | ||
|
||
Code | ||
quartoInspect() | ||
Condition | ||
Error in `quartoInspect()`: | ||
! `quarto` not found. | ||
i Check that it is installed and available on your `PATH`. | ||
|
Oops, something went wrong.