Skip to content

Commit

Permalink
Fix blitz install for recipes that use the path helper (#3995)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dillon Raphael authored Dec 9, 2022
1 parent fe2e4eb commit a059627
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/rude-trainers-visit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"blitz": patch
---

Fix blitz install for recipes that use the path helper to check if ./src/pages directory is available, otherwise use ./pages
17 changes: 14 additions & 3 deletions packages/blitz/src/installer/utils/paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,23 @@ function getBlitzPath(type: string) {
}
}

function findPageDir() {
const srcPagePath = `src/pages`
const srcPage = fs.existsSync(path.resolve(srcPagePath))

if (srcPage) {
return srcPagePath
} else {
return `pages`
}
}

export const paths = {
document() {
return `pages/_document${ext(true)}`
return `${findPageDir()}/_document${ext(true)}`
},
app() {
return `pages/_app${ext(true)}`
return `${findPageDir()}/_app${ext(true)}`
},
blitzServer() {
return getBlitzPath("server")
Expand All @@ -32,7 +43,7 @@ export const paths = {
return getBlitzPath("client")
},
entry() {
return `pages/index${ext(true)}`
return `${findPageDir()}/index${ext(true)}`
},
nextConfig() {
return `next.config.js`
Expand Down

0 comments on commit a059627

Please sign in to comment.