@@ -186,7 +186,7 @@ async function createTests(filePath, funcToTest, processingFunction = 'getUnitTe
186
186
) )
187
187
) ;
188
188
189
- sortFolderTree ( ) ;
189
+ sortFolderTree ( folderStructureTree ) ;
190
190
191
191
for ( const [ i , funcData ] of uniqueFoundFunctions . entries ( ) ) {
192
192
let indexToPush = fileIndex + 1 + i ;
@@ -328,9 +328,9 @@ function updateFolderTree(absolutePath) {
328
328
}
329
329
}
330
330
331
- function sortFolderTree ( ) {
331
+ function sortFolderTree ( tree ) {
332
332
// 1. Sort the folderStructureTree
333
- folderStructureTree . sort ( ( a , b ) => {
333
+ tree . sort ( ( a , b ) => {
334
334
if ( a . absolutePath < b . absolutePath ) {
335
335
return - 1 ;
336
336
}
@@ -341,25 +341,28 @@ function sortFolderTree() {
341
341
} ) ;
342
342
343
343
// 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 ++ ) {
345
345
// Get the current directory path
346
- const currentDirPath = path . dirname ( folderStructureTree [ i ] . absolutePath ) ;
346
+ const currentDirPath = path . dirname ( tree [ i ] . absolutePath ) ;
347
347
// 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 ) {
349
349
// 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 ( "├───" , "└───" ) ;
351
351
}
352
352
}
353
353
}
354
354
355
- async function getFunctionsForExport ( dirPath , ignoreFilesRewrite ) {
355
+ async function getFunctionsForExport ( path , pythagoraRoot , ignoreFilesRewrite ) {
356
356
if ( ignoreFilesRewrite ) {
357
357
isFileToIgnore = ignoreFilesRewrite ;
358
358
}
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 ) ;
361
365
processedFiles = [ ] ;
362
- await traverseDirectory ( rootPath , true ) ;
363
366
return { functionList, folderStructureTree} ;
364
367
}
365
368
@@ -400,5 +403,6 @@ async function generateTestsForDirectory(args, processingFunction = 'getUnitTest
400
403
401
404
module . exports = {
402
405
getFunctionsForExport,
403
- generateTestsForDirectory
406
+ generateTestsForDirectory,
407
+ sortFolderTree
404
408
}
0 commit comments