refactor: gen命令

This commit is contained in:
2023-07-18 11:05:02 +08:00
parent f420d2737e
commit 4137c35a3e

View File

@ -2,8 +2,8 @@
* @Author: zhaojinfeng 121016171@qq.com * @Author: zhaojinfeng 121016171@qq.com
* @Date: 2023-06-20 16:46:04 * @Date: 2023-06-20 16:46:04
* @LastEditors: zhaojinfeng 121016171@qq.com * @LastEditors: zhaojinfeng 121016171@qq.com
* @LastEditTime: 2023-06-21 10:56:31 * @LastEditTime: 2023-07-18 11:04:47
* @FilePath: \tianheng-design\bin\GEN.TS * @FilePath: \vue3\bin\gen.ts
* @Description: * @Description:
* *
*/ */
@ -32,13 +32,18 @@ async function rendenVUE(data: RenderData) {
} }
co(function*() { co(function*() {
const name: string = yield coprompt('起一个组件英文名称(不区分大小写): ') const input: string = yield coprompt('起一个组件英文名称(不区分大小写): ')
if (!name)
if (!input)
throw new Error('不能创建') throw new Error('不能创建')
const lowerName = name.toLowerCase() const lowerName = input.toLowerCase()
const first = lowerName[0] let component = ''
const component = first.toUpperCase() + lowerName.slice(1)
input.split('-').forEach((name) => {
const first = name[0]
component += first.toUpperCase() + name.slice(1)
})
const data = { lowerName, component } const data = { lowerName, component }
Promise Promise
.all([rendenStories(data), rendenVUE(data)]) .all([rendenStories(data), rendenVUE(data)])