File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 4040 ]
4141 },
4242 "scripts" : {
43- "build" : " pnpm lint:fix && tsc --project tsconfig.build.json && pnpm update-commands && chmod +x dist/index.js" ,
43+ "build" : " pnpm format && pnpm lint:fix && tsc --project tsconfig.build.json && pnpm update-commands && chmod +x dist/index.js" ,
4444 "build:clean" : " rm -rf dist && pnpm build" ,
4545 "build:dev" : " tsc --incremental && pnpm update-commands && chmod +x dist/index.js" ,
4646 "build:watch" : " tsc --incremental --watch" ,
Original file line number Diff line number Diff line change @@ -82,7 +82,25 @@ function formatTable(data: unknown, columns?: string[]): string {
8282 if ( firstItem && typeof firstItem === "object" ) {
8383 let selectedColumns : string [ ] ;
8484 if ( columns && columns . length > 0 ) {
85- selectedColumns = columns ;
85+ const allKeys = new Set < string > ( ) ;
86+ for ( const item of arrayData ) {
87+ if ( item && typeof item === "object" ) {
88+ Object . keys ( item as Record < string , unknown > ) . forEach ( ( k ) =>
89+ allKeys . add ( k )
90+ ) ;
91+ }
92+ }
93+ const invalid = columns . filter ( ( c ) => ! allKeys . has ( c ) ) ;
94+ if ( invalid . length > 0 ) {
95+ console . error (
96+ // eslint-disable-line no-console
97+ `Warning: unknown column(s): ${ invalid . join ( ", " ) } . Available: ${ [ ...allKeys ] . join ( ", " ) } `
98+ ) ;
99+ }
100+ selectedColumns = columns . filter ( ( c ) => allKeys . has ( c ) ) ;
101+ if ( selectedColumns . length === 0 ) {
102+ selectedColumns = [ ...allKeys ] ;
103+ }
86104 } else {
87105 const allKeys = new Set < string > ( ) ;
88106 for ( const item of arrayData ) {
You can’t perform that action at this time.
0 commit comments