nlts
Version:
CommandLine Tool for Node LTS
36 lines (32 loc) • 775 B
JavaScript
const Table = require('cli-table');
const color = require('cli-color');
/** 把list转化成Table输出
* let list = [{
* version: 'v12.13.1',
* date: '2019-11-19',
* npm: '6.12.1',
* v8: '7.7.299.13',
* uv: '1.33.1',
* zlib: '1.2.11',
* openssl: '1.1.1d',
* modules: '72',
* lts: 'Erbium',
* security: false
* }]
*/
const show = (list) => {
if (!list || !list.length) {
return color.red('No matching versions was found!');
}
const headers = Object.keys(list[0]).map(t => color.red(t));
const table = new Table({
head: headers
});
return list.reduce((res, item) => {
res.push(
Object.values(item)
);
return res;
}, table).toString();
}
module.exports = show;