INNER CODE UNIT · TypeScript
build
niraj-khatiwada/ultimate-nestjs-boilerplate · scripts/mail.build.ts:88
async function build(files: string[]) {
await Promise.all(
files.map(async (file) => {
const fileInputPath = path.join(templatesDir, file);
const outputFileName = `${file.slice(0, -'.tsx'.length)}.hbs`;
const fileOutputPath = path.join(outDir, outputFileName);
try {
delete require.cache[require.resolve(fileInputPath)];
// eslint-disable-next-line @typescript-eslint/no-require-imports
const mod = require(fileInputPath);
const Component = mod.default;
if (typeof Component === 'function') {
const html = await render(React.createElement(Component));
const stream = fs.createWriteStream(fileOutputPath);
stream.write(html);
stream.end();