@@ -32,7 +32,7 @@ const outputTsv = (data: any, properties?: string[]) => {
3232 return
3333 }
3434
35- properties = properties
35+ properties = properties
3636 ? properties
3737 : Object . keys ( data [ 0 ] ) ;
3838
@@ -44,10 +44,11 @@ const outputTsv = (data: any, properties?: string[]) => {
4444 for ( const item of data ) {
4545 const lineValues = [ ] ;
4646 for ( const propIndex in properties ) {
47- const value = `${ item [ properties [ propIndex ] ] } ` ;
47+ const value = item [ properties [ propIndex ] ] ;
48+ const stringValue = `${ value } ` ;
4849
49- if ( longestValues [ propIndex ] < value . length ) {
50- longestValues [ propIndex ] = value . length ;
50+ if ( longestValues [ propIndex ] < stringValue . length ) {
51+ longestValues [ propIndex ] = stringValue . length ;
5152 }
5253
5354 lineValues . push ( value ) ;
@@ -59,12 +60,22 @@ const outputTsv = (data: any, properties?: string[]) => {
5960 lines . forEach ( lineValues => {
6061 let line = '' ;
6162 for ( let i = 0 ; i < lineValues . length ; i ++ ) {
62- // if is last, then don't add padEnd
63- if ( i < lineValues . length ) {
64- line += lineValues [ i ] ? lineValues [ i ] . padEnd ( longestValues [ i ] + 1 ) : '' ;
65- } else {
66- line += lineValues [ i ] ;
67- }
63+ if ( lineValues [ i ] === undefined ) {
64+ line += '' ;
65+ continue ;
66+ }
67+
68+ // if is last, then don't add padEnd
69+ if ( i < lineValues . length - 1 ) {
70+ line += `${ lineValues [ i ] } ` . padEnd ( longestValues [ i ] + 1 ) ;
71+ } else {
72+ if ( typeof lineValues [ i ] === 'string' ) {
73+ line += lineValues [ i ] ; // header row
74+ }
75+ else {
76+ line += lineValues [ i ] . lts ? 'LTS' : 'STS' ;
77+ }
78+ }
6879 }
6980
7081 console . log ( line ) ;
0 commit comments