This commit is contained in:
Jacky Zhao 2025-03-12 22:26:39 -07:00
parent c5a8b199ae
commit 1fb7756c49
3 changed files with 33 additions and 18 deletions

View File

@ -115,9 +115,7 @@ export const myImage: SocialImageOptions["imageStructure"] = (...) => {
> const bodyWeight: FontWeight = 400 > const bodyWeight: FontWeight = 400
> >
> const [header, body] = await Promise.all( > const [header, body] = await Promise.all(
> [headerFont, bodyFont].map((font) => > [headerFont, bodyFont].map((font) => fs.promises.readFile(path.resolve(font))),
> fs.promises.readFile(path.resolve(font))
> ),
> ) > )
> >
> return [ > return [

View File

@ -250,15 +250,25 @@ async function partialRebuildFromEntrypoint(
([_node, vfile]) => !toRemove.has(vfile.data.filePath!), ([_node, vfile]) => !toRemove.has(vfile.data.filePath!),
) )
const emittedFps = await emitter.emit(ctx, files, staticResources) const emitted = await emitter.emit(ctx, files, staticResources)
if (Symbol.asyncIterator in emitted) {
if (ctx.argv.verbose) { // Async generator case
for (const file of emittedFps) { for await (const file of emitted) {
console.log(`[emit:${emitter.name}] ${file}`) emittedFiles++
if (ctx.argv.verbose) {
console.log(`[emit:${emitter.name}] ${file}`)
}
}
} else {
// Array case
emittedFiles += emitted.length
if (ctx.argv.verbose) {
for (const file of emitted) {
console.log(`[emit:${emitter.name}] ${file}`)
}
} }
} }
emittedFiles += emittedFps.length
continue continue
} }
@ -280,15 +290,24 @@ async function partialRebuildFromEntrypoint(
.filter((file) => !toRemove.has(file)) .filter((file) => !toRemove.has(file))
.map((file) => contentMap.get(file)!) .map((file) => contentMap.get(file)!)
const emittedFps = await emitter.emit(ctx, upstreamContent, staticResources) const emitted = await emitter.emit(ctx, upstreamContent, staticResources)
if (Symbol.asyncIterator in emitted) {
if (ctx.argv.verbose) { // Async generator case
for (const file of emittedFps) { for await (const file of emitted) {
console.log(`[emit:${emitter.name}] ${file}`) emittedFiles++
if (ctx.argv.verbose) {
console.log(`[emit:${emitter.name}] ${file}`)
}
}
} else {
// Array case
emittedFiles += emitted.length
if (ctx.argv.verbose) {
for (const file of emitted) {
console.log(`[emit:${emitter.name}] ${file}`)
}
} }
} }
emittedFiles += emittedFps.length
} }
} }

View File

@ -20,9 +20,7 @@ export async function emitContent(ctx: BuildCtx, content: ProcessedContent[]) {
const emitted = await emitter.emit(ctx, content, staticResources) const emitted = await emitter.emit(ctx, content, staticResources)
if (Symbol.asyncIterator in emitted) { if (Symbol.asyncIterator in emitted) {
// Async generator case // Async generator case
const files: string[] = []
for await (const file of emitted) { for await (const file of emitted) {
files.push(file)
emittedFiles++ emittedFiles++
if (ctx.argv.verbose) { if (ctx.argv.verbose) {
console.log(`[emit:${emitter.name}] ${file}`) console.log(`[emit:${emitter.name}] ${file}`)