@@ -40,8 +40,9 @@ async function processFile(filePath) {
4040 let ast = await getAstFromFilePath ( filePath ) ;
4141 let syntaxType = await getModuleTypeFromFilePath ( ast ) ;
4242 processAst ( ast , ( funcName , path , type ) => {
43- if ( type === 'exportFnDef' ) exportsFn . push ( funcName ) ;
44- if ( type === 'exportFn' ) {
43+ if ( type === 'exportFnDef' ) {
44+ exportsFn . push ( funcName ) ;
45+ } else if ( type === 'exportFn' ) {
4546 exportsFn . push ( funcName ) ;
4647 } else if ( type === 'exportObj' ) {
4748 exportsObj . push ( funcName ) ;
@@ -78,7 +79,15 @@ async function processFile(filePath) {
7879
7980async function reformatDataForPythagoraAPI ( funcData , filePath , testFilePath ) {
8081 let relatedCode = _ . groupBy ( funcData . relatedCode , 'fileName' ) ;
81- relatedCode = _ . map ( relatedCode , ( value , key ) => ( { fileName : key , functionNames : value . map ( item => item . funcName ) } ) ) ;
82+ // TODO add check if there are more functionNames than 1 while exportedAsObject is true - this shouldn't happen ever
83+ relatedCode = _ . map ( relatedCode , ( value , key ) => {
84+ return {
85+ fileName : key ,
86+ functionNames : value . map ( item => item . funcName ) ,
87+ exportedAsObject : value [ 0 ] . exportedAsObject ,
88+ syntaxType : value [ 0 ] . syntaxType
89+ }
90+ } ) ;
8291 let relatedCodeInSameFile = [ funcData . functionName ] ;
8392 funcData . relatedCode = [ ] ;
8493 for ( const file of relatedCode ) {
@@ -92,6 +101,9 @@ async function reformatDataForPythagoraAPI(funcData, filePath, testFilePath) {
92101 funcData . relatedCode . push ( {
93102 fileName,
94103 code,
104+ functionNames : file . functionNames ,
105+ exportedAsObject : file . exportedAsObject ,
106+ syntaxType : file . syntaxType ,
95107 pathRelativeToTest : getRelativePath ( fullPath , testFilePath + '/brija.test.js' )
96108 } ) ;
97109 }
0 commit comments