代码拉取完成,页面将自动刷新
/*
* @Author : wfl
* @LastEditors : wfl
* @description :
* @updateInfo :
* @Date : 2024-03-19 18:06:22
* @LastEditTime : 2024-03-19 19:14:57
*/
import fs from 'node:fs'
import path from 'node:path'
import picocolors from 'picocolors'
const { green } = picocolors
function readDir(dirPath, parentName = '') {
const stats = fs.statSync(dirPath)
const name = path.basename(dirPath)
const fullName = parentName ? `${parentName}/${name}` : name
const node = { name: parentName ? fullName : '' }
if (stats.isDirectory()) {
node.children = fs.readdirSync(dirPath).map(child =>
readDir(path.join(dirPath, child), fullName))
}
return node
}
const structure = JSON.stringify(readDir('./main-app/views'), null, 2)
const structure2 = JSON.stringify(readDir('./micro-app/views'), null, 2)
const floder = {
'main-app': JSON.parse(structure.replaceAll('views/', '')).children,
'micro-app': JSON.parse(structure2.replaceAll('views/', '')).children,
}
fs.writeFile('main-app/folder.json', JSON.stringify(floder), 'utf8', (err) => {
if (err) { throw err }
console.info(green('Iking-Admin: [文件已更新! 请刷新页面后查看]'))
})
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。