@@ -416,50 +416,55 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
416416 moduleName : keyof typeof config . moduleConfig | keyof typeof config . ReportTitleForEntries ,
417417 listOfMissingRefs : Record < string , any > ,
418418 ) : Promise < void > {
419- const csvPath = join ( this . sharedConfig . reportPath , `${ moduleName } .csv` ) ;
420-
421- return new Promise < void > ( ( resolve , reject ) => {
422- // file deepcode ignore MissingClose: Will auto close once csv stream end
423- const ws = createWriteStream ( csvPath ) . on ( 'error' , reject ) ;
424- const defaultColumns = Object . keys ( OutputColumn ) ;
425- const userDefinedColumns = this . sharedConfig . flags . columns ? this . sharedConfig . flags . columns . split ( ',' ) : null ;
426- let missingRefs : RefErrorReturnType [ ] | WorkflowExtensionsRefErrorReturnType [ ] =
427- Object . values ( listOfMissingRefs ) . flat ( ) ;
428- const columns : ( keyof typeof OutputColumn ) [ ] = userDefinedColumns
429- ? [ ...userDefinedColumns , ...defaultColumns . filter ( ( val : string ) => ! userDefinedColumns . includes ( val ) ) ]
430- : defaultColumns ;
431-
432- if ( this . sharedConfig . flags . filter ) {
433- const [ column , value ] : [ keyof typeof OutputColumn , string ] = this . sharedConfig . flags . filter . split ( '=' ) ;
434- // Filter the missingRefs array
435- missingRefs = missingRefs . filter ( ( row ) => {
436- if ( OutputColumn [ column ] in row ) {
437- const rowKey = OutputColumn [ column ] as keyof ( RefErrorReturnType | WorkflowExtensionsRefErrorReturnType ) ;
438- return row [ rowKey ] === value ;
419+ if ( Object . keys ( config . moduleConfig ) . includes ( moduleName ) ) {
420+ const csvPath = join ( this . sharedConfig . reportPath , `${ moduleName } .csv` ) ;
421+ return new Promise < void > ( ( resolve , reject ) => {
422+ // file deepcode ignore MissingClose: Will auto close once csv stream end
423+ const ws = createWriteStream ( csvPath ) . on ( 'error' , reject ) ;
424+ const defaultColumns = Object . keys ( OutputColumn ) ;
425+ const userDefinedColumns = this . sharedConfig . flags . columns ? this . sharedConfig . flags . columns . split ( ',' ) : null ;
426+ let missingRefs : RefErrorReturnType [ ] | WorkflowExtensionsRefErrorReturnType [ ] =
427+ Object . values ( listOfMissingRefs ) . flat ( ) ;
428+ const columns : ( keyof typeof OutputColumn ) [ ] = userDefinedColumns
429+ ? [ ...userDefinedColumns , ...defaultColumns . filter ( ( val : string ) => ! userDefinedColumns . includes ( val ) ) ]
430+ : defaultColumns ;
431+
432+ if ( this . sharedConfig . flags . filter ) {
433+ const [ column , value ] : [ keyof typeof OutputColumn , string ] = this . sharedConfig . flags . filter . split ( '=' ) ;
434+ // Filter the missingRefs array
435+ missingRefs = missingRefs . filter ( ( row ) => {
436+ if ( OutputColumn [ column ] in row ) {
437+ const rowKey = OutputColumn [ column ] as keyof ( RefErrorReturnType | WorkflowExtensionsRefErrorReturnType ) ;
438+ return row [ rowKey ] === value ;
439+ }
440+ return false ;
441+ } ) ;
442+ }
443+
444+ const rowData : Record < string , string | string [ ] > [ ] = [ ] ;
445+ for ( const issue of missingRefs ) {
446+ let row : Record < string , string | string [ ] > = { } ;
447+
448+ for ( const column of columns ) {
449+ if ( Object . keys ( issue ) . includes ( OutputColumn [ column ] ) ) {
450+ const issueKey = OutputColumn [ column ] as keyof typeof issue ;
451+ row [ column ] = issue [ issueKey ] as string ;
452+ row [ column ] = typeof row [ column ] === 'object' ? JSON . stringify ( row [ column ] ) : row [ column ] ;
453+ }
439454 }
440- return false ;
441- } ) ;
442- }
443-
444- const rowData : Record < string , string | string [ ] > [ ] = [ ] ;
445- for ( const issue of missingRefs ) {
446- let row : Record < string , string | string [ ] > = { } ;
447-
448- for ( const column of columns ) {
449- if ( Object . keys ( issue ) . includes ( OutputColumn [ column ] ) ) {
450- const issueKey = OutputColumn [ column ] as keyof typeof issue ;
451- row [ column ] = issue [ issueKey ] as string ;
452- row [ column ] = typeof row [ column ] === 'object' ? JSON . stringify ( row [ column ] ) : row [ column ] ;
455+
456+ if ( this . currentCommand === 'cm:stacks:audit:fix' ) {
457+ row [ 'Fix status' ] = row . fixStatus ;
453458 }
459+
460+ rowData . push ( row ) ;
454461 }
455-
456- if ( this . currentCommand === 'cm:stacks:audit:fix' ) {
457- row [ 'Fix status' ] = row . fixStatus ;
458- }
459-
460- rowData . push ( row ) ;
461- }
462- csv . write ( rowData , { headers : true } ) . pipe ( ws ) . on ( 'error' , reject ) . on ( 'finish' , resolve ) ;
463- } ) ;
462+ csv . write ( rowData , { headers : true } ) . pipe ( ws ) . on ( 'error' , reject ) . on ( 'finish' , resolve ) ;
463+ } ) ;
464+ } else {
465+ return new Promise < void > ( ( reject ) => {
466+ return reject ( )
467+ } )
468+ }
464469 }
465470}
0 commit comments