@@ -13,13 +13,11 @@ program.parse();
1313
1414const argv = program . args ;
1515
16-
1716const path = argv [ 0 ] ;
1817
1918const options = program . opts ( ) ;
2019
2120
22-
2321if ( argv . length < 1 ) {
2422 console . error ( "You must pass at least one path!" ) ;
2523 process . exit ( 1 ) ;
@@ -32,6 +30,11 @@ function counter(item) {
3230 return { lines, words, characters } ;
3331}
3432
33+ let totalLines = 0 ;
34+ let totalWords = 0 ;
35+ let totalCharacters = 0 ;
36+ let fileCount = 0 ;
37+
3538for ( const path of argv ) {
3639 const pathInfo = await stat ( path ) ;
3740
@@ -43,6 +46,12 @@ if (pathInfo.isFile()) {
4346 } else {
4447 console . log ( `${ stats . lines } ${ stats . words } ${ stats . characters } ${ path } ` ) ;
4548 }
49+
50+ totalLines += stats . lines ;
51+ totalWords += stats . words ;
52+ totalCharacters += stats . characters ;
53+ fileCount ++ ;
54+
4655} else if ( pathInfo . isDirectory ( ) ) {
4756 const files = await fs . readdir ( path ) ;
4857 for ( const file of files ) {
@@ -55,6 +64,11 @@ if (pathInfo.isFile()) {
5564 } else {
5665 console . log ( `${ stats . lines } ${ stats . words } ${ stats . characters } ${ filePath } ` ) ;
5766 }
67+
68+ totalLines += stats . lines ;
69+ totalWords += stats . words ;
70+ totalCharacters += stats . characters ;
71+ fileCount ++ ;
5872 }
5973}
6074
0 commit comments