File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed
implement-shell-tools/cat Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,10 @@ function printFile(filePath, options) {
88 const content = fs . readFileSync ( filePath , "utf-8" ) ;
99 const lines = content . split ( "\n" ) ;
1010
11+ if ( lines . length && lines [ lines . length - 1 ] === "" ) {
12+ lines . pop ( ) ;
13+ }
14+
1115 lines . forEach ( ( line ) => {
1216 let prefix = "" ;
1317
@@ -24,6 +28,7 @@ function printFile(filePath, options) {
2428 } ) ;
2529 } catch ( error ) {
2630 console . error ( `cat: ${ filePath } : ${ error . message } ` ) ;
31+ process . exitCode = 1 ;
2732 }
2833}
2934
@@ -51,6 +56,9 @@ function main() {
5156 }
5257
5358 files . forEach ( ( file ) => {
59+ if ( options . numberMode ) {
60+ globalLineCounter = 1 ; //reset line counter for each file if numbering is enabled
61+ }
5462 printFile ( file , options ) ;
5563 } ) ;
5664}
You can’t perform that action at this time.
0 commit comments