@@ -5,7 +5,6 @@ import type {
55 Diagnostic ,
66 DiagnosticWithLocation ,
77 MatchesPattern ,
8- ParseCSSModuleResult ,
98 Resolver ,
109} from '@css-modules-kit/core' ;
1110import {
@@ -27,7 +26,7 @@ import type { Logger } from './logger/logger.js';
2726/**
2827 * @throws {ReadCSSModuleFileError } When failed to read CSS Module file.
2928 */
30- async function parseCSSModuleByFileName ( fileName : string , config : CMKConfig ) : Promise < ParseCSSModuleResult > {
29+ async function parseCSSModuleByFileName ( fileName : string , config : CMKConfig ) : Promise < CSSModule > {
3130 let text : string ;
3231 try {
3332 text = await readFile ( fileName , 'utf-8' ) ;
@@ -96,19 +95,17 @@ export async function runCMK(args: ParsedArgs, logger: Logger): Promise<void> {
9695 // eslint-disable-next-line n/no-process-exit
9796 process . exit ( 1 ) ;
9897 }
99- const parseResults = await Promise . all ( fileNames . map ( async ( fileName ) => parseCSSModuleByFileName ( fileName , config ) ) ) ;
100- for ( const parseResult of parseResults ) {
101- cssModuleMap . set ( parseResult . cssModule . fileName , parseResult . cssModule ) ;
102- syntacticDiagnostics . push ( ...parseResult . diagnostics ) ;
98+ const cssModules = await Promise . all ( fileNames . map ( async ( fileName ) => parseCSSModuleByFileName ( fileName , config ) ) ) ;
99+ for ( const cssModule of cssModules ) {
100+ cssModuleMap . set ( cssModule . fileName , cssModule ) ;
101+ syntacticDiagnostics . push ( ...cssModule . diagnostics ) ;
103102 }
104103
105104 if ( args . clean ) {
106105 await rm ( config . dtsOutDir , { recursive : true , force : true } ) ;
107106 }
108107 await Promise . all (
109- parseResults . map ( async ( parseResult ) =>
110- writeDtsByCSSModule ( parseResult . cssModule , config , resolver , matchesPattern ) ,
111- ) ,
108+ cssModules . map ( async ( cssModule ) => writeDtsByCSSModule ( cssModule , config , resolver , matchesPattern ) ) ,
112109 ) ;
113110
114111 if ( syntacticDiagnostics . length > 0 ) {
@@ -120,7 +117,7 @@ export async function runCMK(args: ParsedArgs, logger: Logger): Promise<void> {
120117 const getCSSModule = ( path : string ) => cssModuleMap . get ( path ) ;
121118 const exportBuilder = createExportBuilder ( { getCSSModule, matchesPattern, resolver } ) ;
122119 const semanticDiagnostics : Diagnostic [ ] = [ ] ;
123- for ( const { cssModule } of parseResults ) {
120+ for ( const cssModule of cssModules ) {
124121 const diagnostics = checkCSSModule ( cssModule , config , exportBuilder , matchesPattern , resolver , getCSSModule ) ;
125122 semanticDiagnostics . push ( ...diagnostics ) ;
126123 }
0 commit comments