-
Notifications
You must be signed in to change notification settings - Fork 335
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add QUARTO_KNITR_RSCRIPT_ARGS environment variable
to pass some flags to Rscript run by Quarto for knitr engine. This can be useful in specific situation like e.g `--max-connections=258` available in R 4.4, or `--vanilla` Args should be passed a comma separated list of flags. This is for expert use and there is not check done on the argument being support by RScript or not.
- Loading branch information
Showing
5 changed files
with
69 additions
and
9 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,12 @@ | ||
--- | ||
title: Rscript args passed to quarto | ||
format: markdown_strict | ||
--- | ||
|
||
```{r} | ||
#| echo: false | ||
args <- commandArgs(trailingOnly = FALSE) | ||
# keep only flags | ||
args <- args[grep("^--", args)] | ||
args | ||
``` |
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,31 @@ | ||
/* | ||
* cache.test.ts | ||
* | ||
* Copyright (C) 2023 Posit Software, PBC | ||
*/ | ||
import { fileLoader, setEnvVar, restoreEnvVar } from "../../utils.ts"; | ||
import { testRender } from "../render/render.ts"; | ||
import { ensureFileRegexMatches, noErrorsOrWarnings } from "../../verify.ts"; | ||
|
||
// Default case should not error | ||
const rscriptArgsDoc = fileLoader()("knitr/rscript-args.qmd", "markdown_strict"); | ||
testRender(rscriptArgsDoc.input, "markdown_strict", true, [ | ||
noErrorsOrWarnings, | ||
]); | ||
|
||
// Set special flag through env var | ||
let rscriptArgs: string | undefined; | ||
testRender(rscriptArgsDoc.input, "markdown_strict", true, [ | ||
noErrorsOrWarnings, | ||
ensureFileRegexMatches(rscriptArgsDoc.output.outputPath, [ | ||
/"--vanilla"/, /"--max-connection=258"/] | ||
), | ||
], | ||
{ | ||
setup: async () => { | ||
rscriptArgs = setEnvVar("QUARTO_KNITR_RSCRIPT_ARGS", "--vanilla,--max-connections=258"); | ||
}, | ||
teardown: async () => { | ||
restoreEnvVar("QUARTO_KNITR_RSCRIPT_ARGS", rscriptArgs); | ||
}, | ||
}); |
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