Commit 7d63592c authored by devjiwonchoi's avatar devjiwonchoi

debug-build-paths: log matched files with count

parent 001edfe4
...@@ -79,18 +79,20 @@ export async function resolveBuildPaths( ...@@ -79,18 +79,20 @@ export async function resolveBuildPaths(
) )
} }
if (matches.length === 0) { const matchedFiles = matches
.filter((file) => !fs.statSync(path.join(projectDir, file)).isDirectory())
.sort()
if (matchedFiles.length === 0) {
throw new Error(`Pattern "${patterns.join(',')}" did not match any files`) throw new Error(`Pattern "${patterns.join(',')}" did not match any files`)
} }
Log.info( Log.info(
`Pattern "${patterns.join(',')}" did match ${matches.length} file(s)` `Pattern "${patterns.join(',')}" did match ${matchedFiles.length} file(s):\n ${matchedFiles.join('\n ')}`
) )
for (const file of matches) { for (const file of matchedFiles) {
if (!fs.statSync(path.join(projectDir, file)).isDirectory()) { categorizeAndAddPath(file, appPaths, pagePaths)
categorizeAndAddPath(file, appPaths, pagePaths)
}
} }
return { return {
......
...@@ -194,9 +194,8 @@ describe('debug-build-paths', () => { ...@@ -194,9 +194,8 @@ describe('debug-build-paths', () => {
expect(buildResult.cliOutput).toContain('Route (app)') expect(buildResult.cliOutput).toContain('Route (app)')
expect(buildResult.cliOutput).toContain('/blog/[slug]') expect(buildResult.cliOutput).toContain('/blog/[slug]')
expect(buildResult.cliOutput).not.toMatch( // Leading whitespace since the pattern "!app/blog/[slug]/comments/**" is in cliOutput and fails the test.
/[○ƒ] \/blog\/\[slug\]\/comments/ expect(buildResult.cliOutput).not.toContain(' /blog/[slug]/comments')
)
}) })
it('should support multiple negation patterns', async () => { it('should support multiple negation patterns', async () => {
...@@ -257,6 +256,20 @@ describe('debug-build-paths', () => { ...@@ -257,6 +256,20 @@ describe('debug-build-paths', () => {
expect(buildResult.cliOutput).not.toContain('○ /dashboard') expect(buildResult.cliOutput).not.toContain('○ /dashboard')
}) })
it('should list matched files in debug output with indentation', async () => {
const buildResult = await next.build({
args: [
'--debug-build-paths',
'app/**/page.tsx,!app/with-type-error/**',
],
})
expect(buildResult.exitCode).toBe(0)
expect(buildResult.cliOutput).toMatch(
/Pattern "app\/\*\*\/page\.tsx,!app\/with-type-error\/\*\*" did match \d+ file\(s\):/
)
expect(buildResult.cliOutput).toContain('\n app/page.tsx')
})
it('should log when pattern matches files', async () => { it('should log when pattern matches files', async () => {
const buildResult = await next.build({ const buildResult = await next.build({
args: [ args: [
......
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