Skip to content

Commit b1acdc8

Browse files
committed
chore(scripts): 更新new-component
1 parent 6321214 commit b1acdc8

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

scripts/new-component.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { prompt } from 'enquirer';
2-
import { pascalCase } from '@tool-pack/basic';
2+
import { kebabCase, pascalCase } from '@tool-pack/basic';
33
import * as Path from 'path';
44
import Fse from 'fs-extra';
55
import chalk from 'chalk';
@@ -32,20 +32,21 @@ async function run() {
3232
run();
3333

3434
async function getConfig() {
35-
({ name: config.name } = await prompt<{ name: string }>({
35+
const { name } = await prompt<{ name: string }>({
3636
type: 'input',
3737
name: 'name',
38-
message: '输入新组件名(小写英文和连字符"-")',
38+
message: '输入新组件名(英文和连字符"-")',
3939
validate(value: string) {
4040
if (!value) return '组件名不能为空';
41-
const illegalWord = value.replace(/[a-z-]/g, '');
41+
const illegalWord = value.replace(/[a-zA-Z-]/g, '');
4242
if (illegalWord) {
4343
return `包含不支持的字符: [${illegalWord.split('').join(',')}]`;
4444
}
4545
return true;
4646
},
47-
}));
47+
});
4848

49+
config.name = kebabCase(name);
4950
config.componentName = pascalCase(config.name);
5051

5152
const { confirm } = await prompt<{ confirm: boolean }>({

0 commit comments

Comments
 (0)