Created
February 22, 2023 18:12
-
-
Save dkelosky/5076cb5dfbaa289118e98b7b8d29cc76 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import handlebars from "handlebars"; | |
import { existsSync, readFileSync, writeFileSync } from "fs"; | |
import config from "config"; | |
import { basename } from "path"; | |
if (process.argv.length < 3) console.log(`usage \`${basename(process.argv[1])} <template-file>\``),process.exit(1) | |
const templateFile = process.argv[2]; | |
const templateFilePath = `templates/${templateFile}`; | |
const outputFilePath = `out/${templateFile}`; | |
if (!existsSync(templateFilePath)) console.log(`${templateFilePath} does not exit`),process.exit(1) | |
const file = readFileSync(`templates/${templateFile}`).toString(); | |
writeFileSync(outputFilePath, handlebars.compile(file)(config.util.toObject())) | |
console.log(`wrote ${outputFilePath}`); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment