2021-10-14 10:38:45 +00:00
|
|
|
//
|
|
|
|
// Copyright 2021 Vulcanize, Inc.
|
|
|
|
//
|
|
|
|
|
|
|
|
import fs from 'fs';
|
|
|
|
import path from 'path';
|
|
|
|
import Handlebars from 'handlebars';
|
|
|
|
import { Writable } from 'stream';
|
|
|
|
|
|
|
|
const TEMPLATE_FILE = './templates/checkpoint-template.handlebars';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Writes the checkpoint file generated from a template to a stream.
|
|
|
|
* @param outStream A writable output stream to write the checkpoint file to.
|
|
|
|
*/
|
2022-05-26 12:30:17 +00:00
|
|
|
export function exportCheckpoint (outStream: Writable, subgraphPath: string): void {
|
2021-10-14 10:38:45 +00:00
|
|
|
const templateString = fs.readFileSync(path.resolve(__dirname, TEMPLATE_FILE)).toString();
|
|
|
|
const template = Handlebars.compile(templateString);
|
2022-05-26 12:30:17 +00:00
|
|
|
const checkpoint = template({ subgraphPath });
|
2021-10-14 10:38:45 +00:00
|
|
|
outStream.write(checkpoint);
|
|
|
|
}
|