Skip to content

Commit 4433ecb

Browse files
BridgeARtargos
authored andcommitted
lib: refactor cli table
The cli table used multi line template strings which are normally not used in our code base and it also upper cased a regular function name. This is changed by this patch. PR-URL: #20960 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Michaël Zasso <[email protected]>
1 parent f1b18ba commit 4433ecb

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

‎lib/internal/cli_table.js‎

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,31 +51,28 @@ const table = (head, columns) =>{
5151
for(vari=0;i<head.length;i++){
5252
constcolumn=columns[i];
5353
for(varj=0;j<longestColumn;j++){
54-
if(!rows[j])
54+
if(rows[j]===undefined)
5555
rows[j]=[];
56-
constv=rows[j][i]=HasOwnProperty(column,j) ? column[j] : '';
56+
constvalue=rows[j][i]=HasOwnProperty(column,j) ? column[j] : '';
5757
constwidth=columnWidths[i]||0;
58-
constcounted=countSymbols(v);
58+
constcounted=countSymbols(value);
5959
columnWidths[i]=Math.max(width,counted);
6060
}
6161
}
6262

6363
constdivider=columnWidths.map((i)=>
6464
tableChars.middleMiddle.repeat(i+2));
6565

66-
consttl=tableChars.topLeft;
67-
consttr=tableChars.topRight;
68-
constlm=tableChars.leftMiddle;
69-
letresult=`${tl}${divider.join(tableChars.topMiddle)}${tr}
70-
${renderRow(head,columnWidths)}
71-
${lm}${divider.join(tableChars.rowMiddle)}${tableChars.rightMiddle}
72-
`;
66+
letresult=`${tableChars.topLeft}${divider.join(tableChars.topMiddle)}`+
67+
`${tableChars.topRight}\n${renderRow(head,columnWidths)}\n`+
68+
`${tableChars.leftMiddle}${divider.join(tableChars.rowMiddle)}`+
69+
`${tableChars.rightMiddle}\n`;
7370

7471
for(constrowofrows)
7572
result+=`${renderRow(row,columnWidths)}\n`;
7673

77-
result+=`${tableChars.bottomLeft}${
78-
divider.join(tableChars.bottomMiddle)}${tableChars.bottomRight}`;
74+
result+=`${tableChars.bottomLeft}${divider.join(tableChars.bottomMiddle)}`+
75+
tableChars.bottomRight;
7976

8077
returnresult;
8178
};

0 commit comments

Comments
(0)