macos-defaults/build/docsify/write-homepage.js

20 lines
534 B
JavaScript
Raw Normal View History

const fs = require('fs')
const Handlebars = require('handlebars')
module.exports = ({ defaults }, templatesPath, destinationPath) => {
mkdirIfNeededSync(destinationPath)
2020-11-27 12:45:16 +00:00
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 })
}
}