@@ -3,6 +3,7 @@ import fastGlob from "fast-glob";
33import * as path from "node:path" ;
44import type { CLI } from "../types.js" ;
55import { GLOB_IGNORE_PATTERNS } from "./constants.js" ;
6+ import { FilePatternError } from "./FilePatternError.js" ;
67import { lstatSafe } from "./lstatSafe.js" ;
78import { normalizeToPosix } from "./normalizeToPosix.js" ;
89
@@ -12,6 +13,7 @@ export async function parseFilePatterns(
1213) : Promise < string [ ] > {
1314 const seen : Set < string > = new Set ( ) ;
1415 const globFileEndingPattern = getGlobFileEndingsPattern ( cli . fileEndings ) ;
16+ const errorMessages : string [ ] = [ ] ;
1517
1618 const globOptions : Options = {
1719 dot : true ,
@@ -25,9 +27,10 @@ export async function parseFilePatterns(
2527
2628 if ( stat != null ) {
2729 if ( stat . isSymbolicLink ( ) ) {
28- throw new Error (
29- `Specified pattern " ${ pattern } " is a symbolic link. ` ,
30+ errorMessages . push (
31+ `Specified pattern is a symbolic link: ${ pattern } ` ,
3032 ) ;
33+ continue ;
3134 }
3235
3336 if ( stat . isFile ( ) ) {
@@ -40,6 +43,11 @@ export async function parseFilePatterns(
4043 ...globOptions ,
4144 cwd : absolutePath ,
4245 } ) ;
46+ if ( files . length === 0 ) {
47+ errorMessages . push (
48+ `No matching files were found in the directory: ${ pattern } ` ,
49+ ) ;
50+ }
4351 for ( const file of files ) {
4452 seen . add ( path . resolve ( absolutePath , file ) ) ;
4553 }
@@ -49,11 +57,20 @@ export async function parseFilePatterns(
4957
5058 const glob = normalizeToPosix ( pattern ) ;
5159 const files = await fastGlob ( glob , globOptions ) ;
60+ if ( files . length === 0 ) {
61+ errorMessages . push (
62+ `No files matching the pattern were found: ${ pattern } ` ,
63+ ) ;
64+ }
5265 for ( const file of files ) {
5366 seen . add ( path . resolve ( file ) ) ;
5467 }
5568 }
5669
70+ if ( errorMessages . length > 0 ) {
71+ throw new FilePatternError ( errorMessages ) ;
72+ }
73+
5774 return Array . from ( seen ) . sort ( ( a , b ) => a . localeCompare ( b ) ) ;
5875}
5976
0 commit comments