项目中有时候需要生成很多的文件的模板
const fs = require('fs')
const arr = ['approvals', 'attendances', 'departments', 'employees', 'permission', 'salarys', 'setting', 'social']
arr.forEach(item => {
fs.existsSync(item) || fs.mkdirSync(item)
// 创建文件夹
fs.writeFileSync('./' + item + '/index.vue', `
<template>
<div>${item}</div>
</template>
<script>
export default {
name: '${item.slice(0, 1).toUpperCase() + item.slice(1)}View',
components: {},
props: {},
data () {
return {}
},
computed: {},
watch: {},
created () {},
mounted () {},
methods: {}
}
</script>
<style lang="less" scoped>
</style>
`)
})