@@ -176,7 +176,8 @@ async function saveTests(filePath, name, testData) {
176
176
async function traverseDirectory ( directory , onlyCollectFunctionData , prefix = '' , funcName ) {
177
177
if ( await checkPathType ( directory ) === 'file' && ! onlyCollectFunctionData ) {
178
178
if ( path . extname ( directory ) !== '.js' ) throw new Error ( 'File is not a javascript file' ) ;
179
- return await createTests ( directory , prefix , funcName ) ;
179
+ const newPrefix = `| ${ prefix } | ` ;
180
+ return await createTests ( directory , newPrefix , funcName ) ;
180
181
}
181
182
const files = await fs . readdir ( directory ) ;
182
183
for ( const file of files ) {
@@ -187,7 +188,7 @@ async function traverseDirectory(directory, onlyCollectFunctionData, prefix = ''
187
188
if ( ignoreFolders . includes ( path . basename ( absolutePath ) ) || path . basename ( absolutePath ) . charAt ( 0 ) === '.' ) continue ;
188
189
189
190
if ( onlyCollectFunctionData && isPathInside ( path . dirname ( queriedPath ) , absolutePath ) ) {
190
- folderStructureTree . push ( getFolderTreeItem ( prefix , isLast , path . basename ( absolutePath ) , absolutePath ) ) ;
191
+ updateFolderTree ( prefix , isLast , absolutePath )
191
192
}
192
193
193
194
const newPrefix = isLast ? `${ prefix } ` : `${ prefix } | ` ;
@@ -196,7 +197,7 @@ async function traverseDirectory(directory, onlyCollectFunctionData, prefix = ''
196
197
if ( path . extname ( absolutePath ) !== '.js' ) continue ;
197
198
if ( onlyCollectFunctionData ) {
198
199
if ( isPathInside ( path . dirname ( queriedPath ) , absolutePath ) ) {
199
- folderStructureTree . push ( getFolderTreeItem ( prefix , isLast , path . basename ( absolutePath ) , absolutePath ) ) ;
200
+ updateFolderTree ( prefix , isLast , absolutePath ) ;
200
201
}
201
202
await processFile ( absolutePath ) ;
202
203
} else {
@@ -207,6 +208,12 @@ async function traverseDirectory(directory, onlyCollectFunctionData, prefix = ''
207
208
}
208
209
}
209
210
211
+ function updateFolderTree ( prefix , isLast , absolutePath ) {
212
+ if ( ! folderStructureTree . find ( fst => fst . absolutePath === absolutePath ) ) {
213
+ folderStructureTree . push ( getFolderTreeItem ( prefix , isLast , path . basename ( absolutePath ) , absolutePath ) ) ;
214
+ }
215
+ }
216
+
210
217
async function getFunctionsForExport ( dirPath ) {
211
218
rootPath = dirPath ;
212
219
await traverseDirectory ( rootPath , true ) ;
0 commit comments