mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2024-11-27 04:09:51 +08:00
487001d697
.demo.md for component demo .demo-entry.md for demo entry .md for common docs
27 lines
743 B
JavaScript
27 lines
743 B
JavaScript
const fs = require('fs')
|
|
const path = require('path')
|
|
|
|
async function * walk (dir) {
|
|
for await (const d of await fs.promises.opendir(dir)) {
|
|
const entry = path.join(dir, d.name)
|
|
if (d.isDirectory()) yield * walk(entry)
|
|
else if (d.isFile()) yield entry
|
|
}
|
|
}
|
|
|
|
// Then, use it with a simple async for loop
|
|
async function main () {
|
|
for await (const p of walk('./demo/documentation')) {
|
|
// console.log(p)
|
|
// if (/index\.md$/.test(p)) {
|
|
// // console.log(p.replace(/index\.md$/, 'index.demo-entry.md'))
|
|
// fs.renameSync(p, p.replace(/index\.md$/, 'index.demo-entry.md'))
|
|
// }
|
|
if (/\.md$/.test(p) && !/demo-entry\.md$/.test(p)) {
|
|
fs.renameSync(p, p.replace(/\.md$/, '.demo.md'))
|
|
}
|
|
}
|
|
}
|
|
|
|
main()
|