mirror of
https://github.com/yannbertrand/macos-defaults
synced 2024-12-14 05:32:31 +00:00
27 lines
891 B
JavaScript
27 lines
891 B
JavaScript
const fs = require('fs')
|
|
const Handlebars = require('handlebars')
|
|
|
|
module.exports = (defaults, templatesPath, destinationPath) => {
|
|
if (defaults.categories !== undefined) {
|
|
const categoryTemplate = fs.readFileSync(
|
|
`${templatesPath}/category.md.handlebars`,
|
|
'utf8'
|
|
)
|
|
const renderCategory = Handlebars.compile(categoryTemplate)
|
|
defaults.categories.forEach((category) => {
|
|
fs.mkdirSync(`${destinationPath}/${category.folder}`)
|
|
const categoryReadmeContent = renderCategory(category)
|
|
fs.writeFileSync(
|
|
`${destinationPath}/${category.folder}/readme.md`,
|
|
categoryReadmeContent
|
|
)
|
|
|
|
if (category.image !== undefined) {
|
|
fs.copyFileSync(
|
|
`../../images/${category.folder}/${category.image.filename}`,
|
|
`${destinationPath}/${category.folder}/${category.image.filename}`
|
|
)
|
|
}
|
|
})
|
|
}
|
|
}
|