@@ -11,9 +11,9 @@ import path from 'node:path';
1111import { DirectoryFile , FileTree } from '../interfaces' ;
1212
1313/**
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.
1515 * @param {string } srcPath path to source dir
16- * @param {array } exclude exluded file patter list
16+ * @param {array } exclude excluded file patter list
1717 * @param {array } include included file patter list
1818 * @param {string } mainPath path to hold source dir
1919 * @param {object } tree tree array
@@ -49,9 +49,10 @@ export const listFolder = async (
4949 for ( const dirent of dirs ) {
5050 const filePath = path . join ( srcPath , dirent . name ) ;
5151 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 } /` ;
5556
5657 if ( name . endsWith ( 'index' ) ) {
5758 name = srcPath . replace ( / \/ / g, '-' ) + '-' + name ;
0 commit comments