File tree 1 file changed +6
-5
lines changed
1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change 1
1
import { prompt } from 'enquirer' ;
2
- import { pascalCase } from '@tool-pack/basic' ;
2
+ import { kebabCase , pascalCase } from '@tool-pack/basic' ;
3
3
import * as Path from 'path' ;
4
4
import Fse from 'fs-extra' ;
5
5
import chalk from 'chalk' ;
@@ -32,20 +32,21 @@ async function run() {
32
32
run ( ) ;
33
33
34
34
async function getConfig ( ) {
35
- ( { name : config . name } = await prompt < { name : string } > ( {
35
+ const { name } = await prompt < { name : string } > ( {
36
36
type : 'input' ,
37
37
name : 'name' ,
38
- message : '输入新组件名(小写英文和连字符 "-")' ,
38
+ message : '输入新组件名(英文和连字符 "-")' ,
39
39
validate ( value : string ) {
40
40
if ( ! value ) return '组件名不能为空' ;
41
- const illegalWord = value . replace ( / [ a - z - ] / g, '' ) ;
41
+ const illegalWord = value . replace ( / [ a - z A - Z - ] / g, '' ) ;
42
42
if ( illegalWord ) {
43
43
return `包含不支持的字符: [${ illegalWord . split ( '' ) . join ( ',' ) } ]` ;
44
44
}
45
45
return true ;
46
46
} ,
47
- } ) ) ;
47
+ } ) ;
48
48
49
+ config . name = kebabCase ( name ) ;
49
50
config . componentName = pascalCase ( config . name ) ;
50
51
51
52
const { confirm } = await prompt < { confirm : boolean } > ( {
You can’t perform that action at this time.
0 commit comments