mirror of
https://gitee.com/fantastic-admin/basic.git
synced 2024-11-29 10:38:00 +08:00
fix: 修复 plop 无法使用
This commit is contained in:
parent
3c3fbd1ece
commit
2e4af7c2f5
@ -1,4 +1,4 @@
|
||||
const fs = require('node:fs')
|
||||
import fs from 'node:fs'
|
||||
|
||||
function getFolder(path) {
|
||||
const components = []
|
||||
@ -13,7 +13,7 @@ function getFolder(path) {
|
||||
return components
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
description: '创建组件',
|
||||
prompts: [
|
||||
{
|
||||
|
@ -1,5 +1,5 @@
|
||||
const path = require('node:path')
|
||||
const fs = require('node:fs')
|
||||
import path from 'node:path'
|
||||
import fs from 'node:fs'
|
||||
|
||||
function getFolder(path) {
|
||||
const components = []
|
||||
@ -14,7 +14,7 @@ function getFolder(path) {
|
||||
return components
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
description: '创建标准模块 Mock',
|
||||
prompts: [
|
||||
{
|
||||
|
@ -1,5 +1,5 @@
|
||||
const path = require('node:path')
|
||||
const fs = require('node:fs')
|
||||
import path from 'node:path'
|
||||
import fs from 'node:fs'
|
||||
|
||||
function getFolder(path) {
|
||||
const components = []
|
||||
@ -14,7 +14,7 @@ function getFolder(path) {
|
||||
return components
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
description: '创建页面',
|
||||
prompts: [
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
module.exports = {
|
||||
export default {
|
||||
description: '创建全局状态',
|
||||
prompts: [
|
||||
{
|
||||
|
15
plopfile.js
15
plopfile.js
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user