watcher-ts/packages/codegen/src/subscriber.ts
prathamesh0 408a3927c0
Add a table for entites in frothy region for subgraph watchers (#231)
* Add a table for entites in frothy region and update it in a subscriber

* Accommodate changes to other watchers and codegen
2022-11-16 17:12:54 +05:30

22 lines
743 B
TypeScript

//
// Copyright 2022 Vulcanize, Inc.
//
import fs from 'fs';
import path from 'path';
import Handlebars from 'handlebars';
import { Writable } from 'stream';
const SUBSCRIBER_TEMPLATE_FILE = './templates/subscriber-template.handlebars';
/**
* Writes the subscriber file generated from template to a stream.
* @param outStream A writable output stream to write the subscriber file to.
*/
export function exportSubscriber (subscriberOutStream: Writable): void {
const subscriberTemplateString = fs.readFileSync(path.resolve(__dirname, SUBSCRIBER_TEMPLATE_FILE)).toString();
const subscriberTemplate = Handlebars.compile(subscriberTemplateString);
const subscriber = subscriberTemplate({});
subscriberOutStream.write(subscriber);
}