plopfile.js 446 B

12345678910111213
  1. import { promises as fs } from 'node:fs'
  2. export default async function (plop) {
  3. plop.setWelcomeMessage('请选择需要创建的模式:')
  4. const items = await fs.readdir('./plop-templates')
  5. for (const item of items) {
  6. const stat = await fs.lstat(`./plop-templates/${item}`)
  7. if (stat.isDirectory()) {
  8. const prompt = await import(`./plop-templates/${item}/prompt.js`)
  9. plop.setGenerator(item, prompt.default)
  10. }
  11. }
  12. }