@@ -78,11 +78,13 @@ async function generate(argv) {
7878
7979 // iterate through all files in folder
8080 await asyncForEach ( files , async file => {
81- if ( exclude && mm . contains ( `${ chalk . dim ( folder ) } /${ file } ` , exclude ) ) {
81+ let isExcluded = false ;
82+
83+ if ( exclude && mm . isMatch ( path . join ( folder . replace ( srcFolder , '' ) , file ) , exclude ) ) {
8284 console . log ( chalk . reset . inverse . bold . blueBright ( ' EXCLUDE ' ) , `${ chalk . dim ( folder ) } /${ chalk . bold ( file ) } ` ) ;
8385
8486 addToStatistics ( file , 'exclude' ) ;
85- return ;
87+ isExcluded = true ;
8688 }
8789
8890 const stat = await fs . lstat ( `${ folder } /${ file } ` ) ;
@@ -97,9 +99,11 @@ async function generate(argv) {
9799 if ( stat . isDirectory ( folder ) ) {
98100 // check file length and skip empty folders
99101 try {
100- let dirFiles = await fs . readdir ( ` ${ folder } / ${ file } ` ) ;
102+ let dirFiles = await fs . readdir ( path . join ( folder , file ) ) ;
101103
102- dirFiles = dirFiles . filter ( f => ! mm . contains ( f , exclude ) ) ;
104+ dirFiles = dirFiles . filter ( f => {
105+ return ! mm . isMatch ( path . join ( folder . replace ( srcFolder , '' ) , file , f ) , exclude ) ;
106+ } ) ;
103107
104108 if ( dirFiles . length > 0 ) {
105109 await fs . mkdir ( `${ folderPath } /${ file } ` ) ;
@@ -126,7 +130,7 @@ async function generate(argv) {
126130 await readFiles ( `${ folder } /${ file } ` , depth + 1 , tree . filter ( treeItem => file === treeItem . name ) [ 0 ] . children ) ;
127131 }
128132 // Else branch accessed when file is not a folder
129- else {
133+ else if ( ! isExcluded ) {
130134 // check if extension is correct
131135 if ( checkExtension ( file , extensions ) ) {
132136 const fileData = await fs . readFile ( `${ folder } /${ file } ` , 'utf8' ) ;
@@ -229,6 +233,7 @@ async function generate(argv) {
229233
230234 return Promise . resolve ( files ) ;
231235 } catch ( error ) {
236+ console . log ( error ) ;
232237 if ( error . code === 'ENOENT' ) {
233238 console . log ( 'cannot find source folder' ) ;
234239 } else {
@@ -283,7 +288,7 @@ async function generate(argv) {
283288 Object . keys ( statistics ) . map ( w => w . length )
284289 ) ;
285290
286- console . log ( `\n${ Array ( maxExtLength + maxExtLength / 2 ) . join ( '-' ) } ` ) ;
291+ console . log ( `\n${ Array ( maxExtLength ) . join ( '-' ) } ` ) ;
287292
288293 const errorCount = Object . keys ( statistics ) . reduce ( ( b , c ) => b + statistics [ c ] . error , 0 ) ;
289294 // iterate trough stats
@@ -298,13 +303,13 @@ async function generate(argv) {
298303 const total = Object . keys ( statusTypes ) . reduce ( ( before , curr ) => before + types [ curr ] , 0 ) ;
299304
300305 console . log (
301- `${ extension } ${ Array ( maxExtLength - extension . length + maxExtLength / 2 ) . join (
306+ `${ extension } ${ Array ( Math . round ( maxExtLength - extension . length + maxExtLength / 2 ) ) . join (
302307 ' '
303308 ) } | ${ content } - ${ total } total`
304309 ) ;
305310 } ) ;
306311
307- console . log ( `${ Array ( maxExtLength + maxExtLength / 2 ) . join ( '-' ) } \nTime: ${ resultTime } s\n` ) ;
312+ console . log ( `${ Array ( maxExtLength ) . join ( '-' ) } \nTime: ${ resultTime } s\n` ) ;
308313
309314 process . exit ( errorCount ? 1 : 0 ) ;
310315 } ) ;
0 commit comments