@@ -186,7 +186,7 @@ async function createTests(filePath, funcToTest, processingFunction = 'getUnitTe
186186 ) )
187187 ) ;
188188
189- sortFolderTree ( ) ;
189+ sortFolderTree ( folderStructureTree ) ;
190190
191191 for ( const [ i , funcData ] of uniqueFoundFunctions . entries ( ) ) {
192192 let indexToPush = fileIndex + 1 + i ;
@@ -328,9 +328,9 @@ function updateFolderTree(absolutePath) {
328328 }
329329}
330330
331- function sortFolderTree ( ) {
331+ function sortFolderTree ( tree ) {
332332 // 1. Sort the folderStructureTree
333- folderStructureTree . sort ( ( a , b ) => {
333+ tree . sort ( ( a , b ) => {
334334 if ( a . absolutePath < b . absolutePath ) {
335335 return - 1 ;
336336 }
@@ -341,25 +341,28 @@ function sortFolderTree() {
341341 } ) ;
342342
343343 // 2. Set prefix according to the position in the directory
344- for ( let i = 0 ; i < folderStructureTree . length ; i ++ ) {
344+ for ( let i = 0 ; i < tree . length ; i ++ ) {
345345 // Get the current directory path
346- const currentDirPath = path . dirname ( folderStructureTree [ i ] . absolutePath ) ;
346+ const currentDirPath = path . dirname ( tree [ i ] . absolutePath ) ;
347347 // Check if it's the last file in the directory
348- if ( i === folderStructureTree . length - 1 || path . dirname ( folderStructureTree [ i + 1 ] . absolutePath ) !== currentDirPath ) {
348+ if ( i === tree . length - 1 || path . dirname ( tree [ i + 1 ] . absolutePath ) !== currentDirPath ) {
349349 // Update the prefix for the last file in the directory
350- folderStructureTree [ i ] . line = folderStructureTree [ i ] . line . replace ( "├───" , "└───" ) ;
350+ tree [ i ] . line = tree [ i ] . line . replace ( "├───" , "└───" ) ;
351351 }
352352 }
353353}
354354
355- async function getFunctionsForExport ( dirPath , ignoreFilesRewrite ) {
355+ async function getFunctionsForExport ( path , pythagoraRoot , ignoreFilesRewrite ) {
356356 if ( ignoreFilesRewrite ) {
357357 isFileToIgnore = ignoreFilesRewrite ;
358358 }
359- rootPath = dirPath ;
360- await traverseDirectory ( rootPath , true ) ;
359+ queriedPath = path ;
360+ rootPath = pythagoraRoot ;
361+
362+ await traverseDirectory ( queriedPath , true ) ;
363+ processedFiles = [ ] ;
364+ await traverseDirectory ( queriedPath , true ) ;
361365 processedFiles = [ ] ;
362- await traverseDirectory ( rootPath , true ) ;
363366 return { functionList, folderStructureTree} ;
364367}
365368
@@ -400,5 +403,6 @@ async function generateTestsForDirectory(args, processingFunction = 'getUnitTest
400403
401404module . exports = {
402405 getFunctionsForExport,
403- generateTestsForDirectory
406+ generateTestsForDirectory,
407+ sortFolderTree
404408}
0 commit comments