@@ -40,8 +40,9 @@ async function processFile(filePath) {
40
40
let ast = await getAstFromFilePath ( filePath ) ;
41
41
let syntaxType = await getModuleTypeFromFilePath ( ast ) ;
42
42
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' ) {
45
46
exportsFn . push ( funcName ) ;
46
47
} else if ( type === 'exportObj' ) {
47
48
exportsObj . push ( funcName ) ;
@@ -78,7 +79,15 @@ async function processFile(filePath) {
78
79
79
80
async function reformatDataForPythagoraAPI ( funcData , filePath , testFilePath ) {
80
81
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
+ } ) ;
82
91
let relatedCodeInSameFile = [ funcData . functionName ] ;
83
92
funcData . relatedCode = [ ] ;
84
93
for ( const file of relatedCode ) {
@@ -92,6 +101,9 @@ async function reformatDataForPythagoraAPI(funcData, filePath, testFilePath) {
92
101
funcData . relatedCode . push ( {
93
102
fileName,
94
103
code,
104
+ functionNames : file . functionNames ,
105
+ exportedAsObject : file . exportedAsObject ,
106
+ syntaxType : file . syntaxType ,
95
107
pathRelativeToTest : getRelativePath ( fullPath , testFilePath + '/brija.test.js' )
96
108
} ) ;
97
109
}
0 commit comments