Skip to content

Commit

Permalink
fix(templates): 修复reactIndex模版语法错误
Browse files Browse the repository at this point in the history
  • Loading branch information
StreakingMan committed Mar 2, 2022
1 parent 0179a18 commit 1e168fd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion actions/react-comp.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const reactComp = async () => {
]) {
fileGenerator({
templateName,
path: CompName,
pathName: CompName,
option: { compName, CompName },
});
}
Expand Down
4 changes: 2 additions & 2 deletions templates/reactCompIndex.ejs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React, { FC } from 'react'
import classNames from 'classnames'
import classnames from 'classnames'
import style from './index.module.scss'
import <%- CompName %>Props from './interface'

const <%- CompName %>: FC< <%- CompName %>Props > = () => {
return <div className={classnames(style.<%- compName %>)}}"></div>
return <div className={classnames(style.<%- compName %>)}></div>
}

export default <%- CompName %>
12 changes: 10 additions & 2 deletions utils/file-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,17 @@ const fileGenerator = ({ templateName, pathName = '/', option = {} }) => {
ejs.render(template, data)
);

// TODO 正则判断
// 格式化生成配置文件
if (filename.endsWith('.js')) {
execSync(`prettier --write ${path.join(cwd, filename)}`);
if (
filename.endsWith('.js') ||
filename.endsWith('.jsx') ||
filename.endsWith('.ts') ||
filename.endsWith('.tsx')
) {
execSync(
`prettier --write ${path.join(path.join(cwd, pathName), filename)}`
);
}
};

Expand Down

0 comments on commit 1e168fd

Please sign in to comment.