Skip to content

Commit

Permalink
fix: wrong config path when update router
Browse files Browse the repository at this point in the history
  • Loading branch information
dingff committed Jun 12, 2023
1 parent bf1ee3b commit 45a9ced
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/generators/page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ function writeFileErrorHandler(err:any) {
if (err) throw err
}

const updateRouterList = (appPath: string, page: string, updateRouter: { enable: boolean, space: number }) => {
const updateRouterList = (appPath: string, page: string, updateRouter: { enable: boolean, space: number }, configExt: string) => {
if (updateRouter.enable === false) return
const spaces = Array(updateRouter.space || 4).fill(' ').join('')
const configPath = path.join(appPath, 'src/app.config.ts')
const configPath = path.join(appPath, `src/app.config.${configExt}`)
fs.readFile(configPath, 'utf8', (err, data) => {
if (err) throw (err)
const ast = parse(data, {
Expand Down Expand Up @@ -193,6 +193,6 @@ export function pageGenerator({
console.log(chalk.black(`创建文件:${path.join(outputDir, `index.config.${configExt}`)}`))
}
// 更新路由
updateRouterList(appPath, `pages/${pagePath}/index`, updateRouter)
updateRouterList(appPath, `pages/${pagePath}/index`, updateRouter, configExt)
console.log(chalk.green(`页面「${pageName}」创建成功${updateRouter.enable === false ? '' : ',路由已更新'}`))
}

0 comments on commit 45a9ced

Please sign in to comment.