macos-defaults/build/docsify/write-homepage.js
Yann Bertrand a6a996ddd2 🚨 Run Prettier
2020-11-27 14:39:16 +01:00

19 lines
534 B
JavaScript

const fs = require('fs')
const Handlebars = require('handlebars')
module.exports = ({ defaults }, templatesPath, destinationPath) => {
mkdirIfNeededSync(destinationPath)
const homeTemplate = fs.readFileSync(
`${templatesPath}/home.md.handlebars`,
'utf8'
)
const rootReadmeContent = Handlebars.compile(homeTemplate)(defaults)
fs.writeFileSync(`${destinationPath}/readme.md`, rootReadmeContent)
}
const mkdirIfNeededSync = (path) => {
if (!fs.existsSync(path)) {
fs.mkdirSync(path, { recursive: true })
}
}