File tree Expand file tree Collapse file tree 2 files changed +27
-4
lines changed Expand file tree Collapse file tree 2 files changed +27
-4
lines changed Original file line number Diff line number Diff line change @@ -352,6 +352,30 @@ function sortFolderTree() {
352
352
}
353
353
}
354
354
355
+ function sortFolderTree ( ) {
356
+ // 1. Sort the folderStructureTree
357
+ folderStructureTree . sort ( ( a , b ) => {
358
+ if ( a . absolutePath < b . absolutePath ) {
359
+ return - 1 ;
360
+ }
361
+ if ( a . absolutePath > b . absolutePath ) {
362
+ return 1 ;
363
+ }
364
+ return 0 ;
365
+ } ) ;
366
+
367
+ // 2. Set prefix according to the position in the directory
368
+ for ( let i = 0 ; i < folderStructureTree . length ; i ++ ) {
369
+ // Get the current directory path
370
+ const currentDirPath = path . dirname ( folderStructureTree [ i ] . absolutePath ) ;
371
+ // Check if it's the last file in the directory
372
+ if ( i === folderStructureTree . length - 1 || path . dirname ( folderStructureTree [ i + 1 ] . absolutePath ) !== currentDirPath ) {
373
+ // Update the prefix for the last file in the directory
374
+ folderStructureTree [ i ] . line = folderStructureTree [ i ] . line . replace ( "├───" , "└───" ) ;
375
+ }
376
+ }
377
+ }
378
+
355
379
async function getFunctionsForExport ( dirPath , ignoreFilesRewrite ) {
356
380
if ( ignoreFilesRewrite ) {
357
381
isFileToIgnore = ignoreFilesRewrite ;
Original file line number Diff line number Diff line change @@ -17,13 +17,12 @@ function getRelativePath(filePath, referenceFolderPath) {
17
17
return relativePath ;
18
18
}
19
19
20
+
20
21
function getFolderTreeItem ( prefix , absolutePath ) {
21
- const isDirectory = absolutePath . includes ( ':' ) ? false : fsSync . statSync ( absolutePath ) . isDirectory ( ) ;
22
22
return {
23
23
line : `${ prefix } ${ path . basename ( absolutePath ) } ` ,
24
- absolutePath,
25
- isDirectory
26
- } ;
24
+ absolutePath : absolutePath
25
+ }
27
26
}
28
27
29
28
function isPathInside ( basePath , targetPath ) {
You can’t perform that action at this time.
0 commit comments