Skip to content

Commit 8399fb9

Browse files
committed
Render: ability to compose --to all with other formats (e.g. --to all,json)
1 parent 21b495f commit 8399fb9

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

news/changelog-1.2.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777

7878
## Miscellaneous
7979

80+
- Render: ability to compose `--to all` with other formats (e.g. `--to all,json`)
8081
- Don't call Deno.realPathSync on Windows (avoid problems w/ UNC paths)
8182
- Don't include Unicode literals on Windows directly (#2184), thanks @yihui
8283
- Improve YAML validation error messages on values of type object (#2191)

src/command/render/render-contexts.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,19 @@ export async function resolveFormatsFromMetadata(
123123

124124
// determine render formats
125125
const renderFormats: string[] = [];
126-
if (flags?.to === undefined || flags?.to === "all") {
126+
if (flags?.to === undefined) {
127127
renderFormats.push(...formats);
128128
} else if (flags?.to === "default") {
129129
renderFormats.push(formats[0]);
130130
} else {
131-
renderFormats.push(...flags.to.split(","));
131+
const toFormats = flags.to.split(",").flatMap((to) => {
132+
if (to === "all") {
133+
return formats;
134+
} else {
135+
return [to];
136+
}
137+
});
138+
renderFormats.push(...toFormats);
132139
}
133140

134141
const resolved: Record<string, Format> = {};

0 commit comments

Comments
 (0)