Skip to content

Commit

Permalink
get knit command from settings (#841)
Browse files Browse the repository at this point in the history
* get knit command from settings

* configuration option description

* Refine description

* Use a default value

* Update comment

Co-authored-by: Kun Ren <renkun@outlook.com>
  • Loading branch information
xoolive and renkun-ken committed Oct 29, 2021
1 parent 28bb068 commit 33e9998
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1316,6 +1316,11 @@
"default": false,
"markdownDescription": "Should the output file be opened automatically when using knit?\n\nRequires `#r.rmarkdown.knit.useBackgroundProcess#` to be set to `true`."
},
"r.rmarkdown.knit.command": {
"type": "string",
"default": "rmarkdown::render",
"markdownDescription": "Command used to knit a Rmd file if not specified by the frontmatter."
},
"r.rmarkdown.knit.defaults.knitWorkingDirectory": {
"type": "string",
"default": "document directory",
Expand Down
7 changes: 4 additions & 3 deletions src/rmarkdown/knit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export class RMarkdownKnitManager extends RMarkdownManager {
}

// precedence:
// knit > site > none
// knit > site > configuration
if (yamlParams?.['knit']) {
const knitParam = yamlParams['knit'];
knitCommand = outputFormat ?
Expand All @@ -116,9 +116,10 @@ export class RMarkdownKnitManager extends RMarkdownManager {
`rmarkdown::render_site(${docPath}, output_format = '${outputFormat}')` :
`rmarkdown::render_site(${docPath})`;
} else {
const cmd = util.config().get<string>('rmarkdown.knit.command');
knitCommand = outputFormat ?
`rmarkdown::render(${docPath}, output_format = '${outputFormat}')` :
`rmarkdown::render(${docPath})`;
`${cmd}(${docPath}, output_format = '${outputFormat}')` :
`${cmd}(${docPath})`;
}

return knitCommand.replace(/['"]/g, '\'');
Expand Down

0 comments on commit 33e9998

Please sign in to comment.