2021-09-29 04:34:09 +00:00
|
|
|
//
|
|
|
|
// Copyright 2021 Vulcanize, Inc.
|
|
|
|
//
|
|
|
|
|
|
|
|
import fs from 'fs';
|
|
|
|
import path from 'path';
|
|
|
|
import Handlebars from 'handlebars';
|
|
|
|
import { Writable } from 'stream';
|
|
|
|
|
|
|
|
const HOOKS_TEMPLATE_FILE = './templates/hooks-template.handlebars';
|
|
|
|
|
|
|
|
/**
|
2021-10-12 10:32:56 +00:00
|
|
|
* Writes the hooks file generated from template to a stream.
|
2021-09-29 04:34:09 +00:00
|
|
|
* @param outStream A writable output stream to write the hooks file to.
|
|
|
|
*/
|
2021-10-12 10:32:56 +00:00
|
|
|
export function exportHooks (hooksOutStream: Writable): void {
|
2021-09-29 04:34:09 +00:00
|
|
|
const hooksTemplateString = fs.readFileSync(path.resolve(__dirname, HOOKS_TEMPLATE_FILE)).toString();
|
|
|
|
const hooksTemplate = Handlebars.compile(hooksTemplateString);
|
|
|
|
const hooks = hooksTemplate({});
|
|
|
|
hooksOutStream.write(hooks);
|
|
|
|
}
|