Skip to content

Commit 43fbb0c

Browse files
authored
fix: svg overwrite json (antfu-collective#107)
* fix: svg overwrite json * style: fix lint
1 parent d835614 commit 43fbb0c

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/run.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -260,11 +260,6 @@ export async function applyRenderer(
260260
const logPrefix = c.dim`[${renderOptions.name}]`
261261
const dir = resolve(process.cwd(), config.outputDir)
262262
await fsp.mkdir(dir, { recursive: true })
263-
if (renderOptions.formats?.includes('json')) {
264-
const path = join(dir, `${renderOptions.name}.json`)
265-
await fsp.writeFile(path, JSON.stringify(sponsors, null, 2))
266-
t.success(`${logPrefix} Wrote to ${r(path)}`)
267-
}
268263

269264
if (renderOptions.filter)
270265
sponsors = sponsors.filter(s => renderOptions.filter(s, sponsors) !== false)
@@ -274,8 +269,6 @@ export async function applyRenderer(
274269
if (!renderOptions.imageFormat)
275270
renderOptions.imageFormat = 'webp'
276271

277-
t.info(`${logPrefix} Composing SVG...`)
278-
279272
const processingSvg = (async () => {
280273
let svgWebp = await renderer.renderSVG(renderOptions, sponsors)
281274

@@ -297,10 +290,15 @@ export async function applyRenderer(
297290

298291
let data: string | Buffer
299292

300-
if (format === 'svg' || format === 'json') {
293+
if (format === 'svg') {
294+
t.info(`${logPrefix} Composing SVG...`)
301295
data = await processingSvg
302296
}
303297

298+
if (format === 'json') {
299+
data = JSON.stringify(sponsors, null, 2)
300+
}
301+
304302
if (format === 'png' || format === 'webp') {
305303
if (!svgPng) {
306304
// Sharp can't render embedded Webp so re-generate with png

0 commit comments

Comments
 (0)