feat: renderFileToNodeStream(filepath, scope)

This commit is contained in:
harttle
2021-10-03 21:21:25 +08:00
parent dd325362f9
commit 68c4cfcfb6
7 changed files with 107 additions and 4 deletions
+2 -1
View File
@@ -10,7 +10,8 @@ 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)).then(() => emitter.end())
toThenable(this.renderTemplates(templates, ctx, emitter))
.then(() => emitter.end(), err => emitter.error(err))
return emitter.stream
}
public * renderTemplates (templates: Template[], ctx: Context, emitter?: Emitter): IterableIterator<any> {