Commit 896a6c1c authored by Cursor Agent's avatar Cursor Agent Committed by devjiwonchoi

Address review comments

- Fix double-wrapped error: Move the 'no matches' check outside the
  try-catch block so it doesn't get re-wrapped by the glob error handler
- Remove accidentally committed build artifact: Delete
  test/integration/errors-on-output-to-static/static/types/routes.d.ts
- Update test assertions to check for route format (○/ƒ prefix) when
  verifying excluded routes, since log message shows full pattern
parent add2ec93
......@@ -65,25 +65,12 @@ export async function resolveBuildPaths(
? includePatterns[0]
: `{${includePatterns.join(',')}}`
let matches: string[]
try {
const matches = (await glob(combinedPattern, {
matches = (await glob(combinedPattern, {
cwd: projectDir,
ignore: excludePatterns,
})) as string[]
if (matches.length === 0) {
throw new Error(`Pattern "${patterns.join(',')}" did not match any files`)
} else {
Log.info(
`Pattern "${patterns.join(',')}" did match ${matches.length} files`
)
}
for (const file of matches) {
if (!fs.statSync(path.join(projectDir, file)).isDirectory()) {
categorizeAndAddPath(file, appPaths, pagePaths)
}
}
} catch (error) {
throw new Error(
`Failed to resolve pattern "${patterns.join(',')}": ${
......@@ -92,6 +79,18 @@ export async function resolveBuildPaths(
)
}
if (matches.length === 0) {
throw new Error(`Pattern "${patterns.join(',')}" did not match any files`)
}
Log.info(`Pattern "${patterns.join(',')}" did match ${matches.length} files`)
for (const file of matches) {
if (!fs.statSync(path.join(projectDir, file)).isDirectory()) {
categorizeAndAddPath(file, appPaths, pagePaths)
}
}
return {
appPaths: Array.from(appPaths).sort(),
pagePaths: Array.from(pagePaths).sort(),
......
// This is an auto-generated entry file that re-exports route types.
// Do not edit this file directly.
export type * from './../../.next/types/route-types.d.ts'
......@@ -159,8 +159,8 @@ describe('debug-build-paths', () => {
expect(buildResult.cliOutput).toContain('○ /about')
expect(buildResult.cliOutput).toContain('○ /dashboard')
expect(buildResult.cliOutput).toContain('/blog/[slug]')
// Should not build routes not specified (check route format, not just substring)
expect(buildResult.cliOutput).not.toMatch(/[○ƒ] \/with-type-error/)
// Should not build routes not specified
expect(buildResult.cliOutput).not.toContain('/with-type-error')
// Should not build pages routes
expect(buildResult.cliOutput).not.toContain('Route (pages)')
})
......@@ -179,7 +179,6 @@ describe('debug-build-paths', () => {
expect(buildResult.cliOutput).toContain('○ /about')
expect(buildResult.cliOutput).toContain('○ /dashboard')
expect(buildResult.cliOutput).toContain('/blog/[slug]')
// Check that the route is not in the build output (not just anywhere in the log)
expect(buildResult.cliOutput).not.toMatch(/[○ƒ] \/with-type-error/)
})
......@@ -194,7 +193,6 @@ describe('debug-build-paths', () => {
expect(buildResult.cliOutput).toContain('Route (app)')
expect(buildResult.cliOutput).toContain('/blog/[slug]')
// Check that the route is not in the build output (not just anywhere in the log)
expect(buildResult.cliOutput).not.toMatch(
/[○ƒ] \/blog\/\[slug\]\/comments/
)
......@@ -212,7 +210,6 @@ describe('debug-build-paths', () => {
expect(buildResult.cliOutput).toContain('Route (app)')
expect(buildResult.cliOutput).toContain('○ /')
expect(buildResult.cliOutput).toContain('○ /about')
// Check that routes are not in the build output (not just anywhere in the log)
expect(buildResult.cliOutput).not.toMatch(/[○ƒ] \/with-type-error/)
expect(buildResult.cliOutput).not.toContain('○ /dashboard')
})
......@@ -228,7 +225,6 @@ describe('debug-build-paths', () => {
expect(buildResult.cliOutput).toContain('○ /')
expect(buildResult.cliOutput).toContain('○ /about')
expect(buildResult.cliOutput).toContain('○ /foo')
// Check that the route is not in the build output (not just anywhere in the log)
expect(buildResult.cliOutput).not.toMatch(/[○ƒ] \/with-type-error/)
})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment