fix: renderToNodeStream() now emit 'error' event instead of throw

This commit is contained in:
harttle
2021-10-03 22:32:00 +08:00
parent 3b5eb6664f
commit afeef1d745
5 changed files with 33 additions and 45 deletions
+1 -1
View File
@@ -10,7 +10,7 @@ import { KeepingTypeEmitter } from '../emitters/keeping-type-emitter'
export class Render {
public renderTemplatesToNodeStream (templates: Template[], ctx: Context): NodeJS.ReadableStream {
const emitter = new StreamedEmitter()
toThenable(this.renderTemplates(templates, ctx, emitter))
Promise.resolve().then(() => toThenable(this.renderTemplates(templates, ctx, emitter)))
.then(() => emitter.end(), err => emitter.error(err))
return emitter.stream
}