@@ -11,9 +11,9 @@ import path from 'node:path';
11
11
import { DirectoryFile , FileTree } from '../interfaces' ;
12
12
13
13
/**
14
- * Recursively traverse folders and return exluded files, a file list and a file tree.
14
+ * Recursively traverse folders and return excluded files, a file list and a file tree.
15
15
* @param {string } srcPath path to source dir
16
- * @param {array } exclude exluded file patter list
16
+ * @param {array } exclude excluded file patter list
17
17
* @param {array } include included file patter list
18
18
* @param {string } mainPath path to hold source dir
19
19
* @param {object } tree tree array
@@ -49,9 +49,10 @@ export const listFolder = async (
49
49
for ( const dirent of dirs ) {
50
50
const filePath = path . join ( srcPath , dirent . name ) ;
51
51
const isDir = dirent . isDirectory ( ) ;
52
- const ext = path . extname ( filePath ) ;
53
- let name = path . basename ( filePath ) . replace ( ext , '' ) ;
54
- const folder = filePath . replace ( name , '' ) . replace ( ext , '' ) ;
52
+ const parsed = path . parse ( filePath ) ;
53
+ const ext = parsed . ext ;
54
+ let name = parsed . name ;
55
+ const folder = `${ parsed . dir } /` ;
55
56
56
57
if ( name . endsWith ( 'index' ) ) {
57
58
name = srcPath . replace ( / \/ / g, '-' ) + '-' + name ;
0 commit comments