@@ -7,7 +7,7 @@ import * as path from 'path';
77 * @param isDebugEnabled - Whether debugging is enabled
88 */
99export function log ( message : string , isDebugEnabled : boolean ) : void {
10- if ( isDebugEnabled ) return ;
10+ if ( ! isDebugEnabled ) return ;
1111 console . info ( message ) ;
1212}
1313
@@ -19,7 +19,8 @@ export function log(message: string, isDebugEnabled: boolean): void {
1919export function isValidClassName ( className : string ) : boolean {
2020 // Class names must start with a letter, underscore, or hyphen
2121 // and can be followed by letters, numbers, underscores, or hyphens
22- return / ^ - ? [ _ a - z A - Z ] + [ _ a - z A - Z 0 - 9 - ] * $ / . test ( className ) ;
22+ const CLASS_NAME_REGEX = / ^ - ? [ _ a - z A - Z ] + [ _ a - z A - Z 0 - 9 - ] * $ / ;
23+ return CLASS_NAME_REGEX . test ( className ) ;
2324}
2425
2526interface FileInfo {
@@ -35,17 +36,21 @@ interface FileInfo {
3536 */
3637export function findFiles ( dir : string , pattern : RegExp ) : FileInfo [ ] {
3738 const files : FileInfo [ ] = [ ] ;
38- const findFilesRecursive = ( currentDir : string ) => {
39- const dirFiles = fs . readdirSync ( currentDir ) ;
40- dirFiles . forEach ( ( file ) => {
41- const fullPath = path . join ( currentDir , file ) ;
42- if ( fs . statSync ( fullPath ) . isDirectory ( ) ) {
39+
40+ function findFilesRecursive ( currentDir : string ) : void {
41+ const dirEntries = fs . readdirSync ( currentDir , { withFileTypes : true } ) ;
42+
43+ for ( const entry of dirEntries ) {
44+ const fullPath = path . join ( currentDir , entry . name ) ;
45+
46+ if ( entry . isDirectory ( ) ) {
4347 findFilesRecursive ( fullPath ) ;
44- } else if ( pattern . test ( file ) ) {
45- files . push ( { name : file , path : fullPath } ) ;
48+ } else if ( pattern . test ( entry . name ) ) {
49+ files . push ( { name : entry . name , path : fullPath } ) ;
4650 }
47- } ) ;
48- } ;
51+ }
52+ }
53+
4954 findFilesRecursive ( dir ) ;
5055 return files ;
5156}
0 commit comments