|
7 | 7 | */
|
8 | 8 |
|
9 | 9 | module.exports = routes => {
|
| 10 | + |
| 11 | + let out = '' |
| 12 | + |
10 | 13 | // Calculate column widths
|
11 | 14 | let widths = routes.reduce((acc,row) => {
|
12 |
| - return [Math.max(acc[0],row[0].length),Math.max(acc[1],row[1].length)] |
| 15 | + return [ |
| 16 | + Math.max(acc[0],Math.max(6,row[0].length)), |
| 17 | + Math.max(acc[1],Math.max(5,row[1].length)) |
| 18 | + ] |
13 | 19 | },[0,0])
|
14 | 20 |
|
15 |
| - console.log('╔══' + ''.padEnd(widths[0],'═') + '══╤══' + ''.padEnd(widths[1],'═') + '══╗') |
16 |
| - console.log('║ ' + "\u001b[1m" + 'METHOD'.padEnd(widths[0]) + "\u001b[0m" + ' │ ' + "\u001b[1m" + 'ROUTE'.padEnd(widths[1]) + "\u001b[0m" + ' ║') |
17 |
| - console.log('╟──' + ''.padEnd(widths[0],'─') + '──┼──' + ''.padEnd(widths[1],'─') + '──╢') |
| 21 | + out += '╔══' + ''.padEnd(widths[0],'═') + '══╤══' + ''.padEnd(widths[1],'═') + '══╗\n' |
| 22 | + out += '║ ' + '\u001b[1m' + 'METHOD'.padEnd(widths[0]) + '\u001b[0m' + ' │ ' + '\u001b[1m' + 'ROUTE'.padEnd(widths[1]) + '\u001b[0m' + ' ║\n' |
| 23 | + out += '╟──' + ''.padEnd(widths[0],'─') + '──┼──' + ''.padEnd(widths[1],'─') + '──╢\n' |
18 | 24 | routes.forEach((route,i) => {
|
19 |
| - console.log('║ ' + route[0].padEnd(widths[0]) + ' │ ' + route[1].padEnd(widths[1]) + ' ║') |
20 |
| - if (i < routes.length-1) { console.log('╟──' + ''.padEnd(widths[0],'─') + '──┼──' + ''.padEnd(widths[1],'─') + '──╢') } |
| 25 | + out += '║ ' + route[0].padEnd(widths[0]) + ' │ ' + route[1].padEnd(widths[1]) + ' ║\n' |
| 26 | + if (i < routes.length-1) { |
| 27 | + out += '╟──' + ''.padEnd(widths[0],'─') + '──┼──' + ''.padEnd(widths[1],'─') + '──╢\n' |
| 28 | + } // end if |
21 | 29 | })
|
22 |
| - console.log('╚══' + ''.padEnd(widths[0],'═') + '══╧══' + ''.padEnd(widths[1],'═') + '══╝') |
| 30 | + out += '╚══' + ''.padEnd(widths[0],'═') + '══╧══' + ''.padEnd(widths[1],'═') + '══╝' |
| 31 | + |
| 32 | + return out |
23 | 33 | }
|
0 commit comments