mirror of
https://github.com/yannbertrand/macos-defaults
synced 2024-12-21 00:43:09 +00:00
16 lines
522 B
JavaScript
16 lines
522 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 })
|
|
}
|
|
}
|