@@ -12,31 +12,21 @@ function isCSSX(filePath: string): boolean {
1212 const content = fs . readFileSync ( filePath , 'utf8' ) ;
1313 const sourceFile = ts . createSourceFile ( filePath , content , ts . ScriptTarget . Latest , true ) ;
1414
15- let isUsed = false ;
16-
17- function checkNode ( node : ts . Node ) {
15+ const checker = ( node : ts . Node ) : boolean => {
1816 if ( ts . isPropertyAccessExpression ( node ) && ts . isIdentifier ( node . name ) ) {
1917 const expressionText = node . expression . getText ( sourceFile ) ;
2018 const methodName = node . name . getText ( sourceFile ) ;
21- const methods = [ 'create' , 'set' , 'root' , 'global' ] ;
22- if ( expressionText === 'cssx' && methods . includes ( methodName ) ) {
23- isUsed = true ;
24- }
19+ return expressionText === 'cssx' && [ 'create' , 'set' , 'root' , 'global' ] . includes ( methodName ) ;
2520 }
21+ return ts . forEachChild ( node , checker ) || false ;
22+ } ;
2623
27- ts . forEachChild ( node , checkNode ) ;
28- }
29-
30- checkNode ( sourceFile ) ;
31-
32- return isUsed ;
24+ return checker ( sourceFile ) ;
3325}
3426
3527async function getAppRoot ( ) : Promise < string > {
3628 const threeLevelsUp = path . join ( process . cwd ( ) , '../../../../..' ) ;
37- const pnpmExists = fs . existsSync ( path . join ( threeLevelsUp , 'node_modules/.pnpm' ) ) ;
38-
39- return pnpmExists ? path . join ( process . cwd ( ) , '../../../../../' ) : path . join ( process . cwd ( ) , '../../' ) ;
29+ return fs . existsSync ( path . join ( threeLevelsUp , 'node_modules/.pnpm' ) ) ? path . join ( process . cwd ( ) , '../../../../../' ) : path . join ( process . cwd ( ) , '../../' ) ;
4030}
4131
4232( async ( ) => {
@@ -45,9 +35,8 @@ async function getAppRoot(): Promise<string> {
4535 const files = await fg ( [ path . join ( appRoot , '**/*.{ts,tsx}' ) ] ) ;
4636 const styleFiles = files . filter ( isCSSX ) ;
4737 console . log ( '\n💬 The following CSS caches were accepted:\n' ) ;
48- for ( const file of styleFiles ) {
49- const filePath = path . resolve ( file ) ;
50- await import ( filePath ) ;
38+ for ( let i = 0 ; i < styleFiles . length ; i ++ ) {
39+ await import ( path . resolve ( styleFiles [ i ] ) ) ;
5140 createBuildIn ( ) ;
5241 setBuildIn ( ) ;
5342 globalBuildIn ( ) ;
0 commit comments