Skip to content

Commit

Permalink
feat: Merge pull request #57 from seamapi/fix-skip-generate-routes
Browse files Browse the repository at this point in the history
always generate routes on nsm build command
  • Loading branch information
itelo authored Sep 14, 2023
2 parents c5214ca + f91ffc1 commit f862615
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 26 deletions.
40 changes: 15 additions & 25 deletions lib/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const build = async ({
skipBuild = false,
nextless = false,
onlyApiFiles = false,
skipNextBuild = false,
skipNextBuild = false
}) => {
if (skipNextBuild) {
console.log("Deprecated. Use --skip-build and/or --nextless instead")
Expand Down Expand Up @@ -58,36 +58,26 @@ const build = async ({

logv({ skipBuild, onlyApiFiles })

if (!skipBuild) {
const executionOptions = nextless
? getNextlessOptions({
dir,
})
: getNextjsOptions({
packageDirWithNext,
dir,
})
const executionOptions = nextless
? getNextlessOptions({
dir,
})
: getNextjsOptions({
packageDirWithNext,
dir,
})

if (!skipBuild) {
// Run the build command
logv("building...")
await executionOptions.build(dir, null, false, false, false)
// Run the generateRoutes command
logv("generating routes...")
await executionOptions.generateRoutes({
onlyApiFiles,
skipBuild,
})
}

// The "generate_routes.ts" file will be generated by searching for source files instead of transpiled ones.
// super useful for tests
if (nextless && skipBuild) {
logv("generating routes...")
await getNextlessOptions({ dir }).generateRoutes({
onlyApiFiles,
skipBuild,
})
}
logv("generating routes...")
await executionOptions.generateRoutes({
onlyApiFiles,
skipBuild,
})

logv("copying nextjs config...")
await require(`${dir}/.nsm/scripts/copy-nextjs-config.js`).copyNextjsConfig()
Expand Down
2 changes: 1 addition & 1 deletion lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ async function main() {
skipBuild: argv["skip-build"],
nextless: argv["nextless"],
onlyApiFiles: argv["only-api-files"],
skipNextBuild: argv["skip-next-build"],
skipNextBuild: argv["skip-next-build"]
})
break
}
Expand Down

0 comments on commit f862615

Please sign in to comment.