import fs from 'fs'; import Handlebars from 'handlebars'; import path from 'path'; import colors from 'colors'; export async function buildTemplates(storybookPath: string) { console.log(colors.blue(`\tbuild templates...`)); const TEMPLATE_PATH = path.resolve(__dirname, '../../templates/base'); fs.readdirSync(TEMPLATE_PATH) .forEach(file => { const outputPath = path.resolve(storybookPath, file); const inputTemplate = fs.readFileSync(path.resolve(TEMPLATE_PATH, file), 'utf-8'); fs.writeFileSync(outputPath, Handlebars.compile(inputTemplate)({})); console.log(`\t\t${outputPath}`); }); }