-
Notifications
You must be signed in to change notification settings - Fork 323
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
19 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
module.exports = { | ||
export default { | ||
description: '创建全局状态', | ||
prompts: [ | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,13 @@ | ||
const fs = require('node:fs') | ||
import { promises as fs } from 'node:fs' | ||
|
||
module.exports = function (plop) { | ||
export default async function (plop) { | ||
plop.setWelcomeMessage('请选择需要创建的模式:') | ||
fs.readdirSync('./plop-templates').forEach((item) => { | ||
fs.lstatSync(`./plop-templates/${item}`).isDirectory() && plop.setGenerator(item, require(`./plop-templates/${item}/prompt`)) | ||
}) | ||
const items = await fs.readdir('./plop-templates') | ||
for (const item of items) { | ||
const stat = await fs.lstat(`./plop-templates/${item}`) | ||
if (stat.isDirectory()) { | ||
const prompt = await import(`./plop-templates/${item}/prompt.js`) | ||
plop.setGenerator(item, prompt.default) | ||
} | ||
} | ||
} |