UNPKG

particle-cli

Version:

Simple Node commandline application for working with your Particle devices and using the Particle Cloud

31 lines (24 loc) 843 B
'use strict'; const chalk = require('chalk'); module.exports.formatLibrary = (library, excludeBadges = []) => { const badges = []; if (library.official && !excludeBadges.official) { badges.push(chalk.green('[official] ')); } else { if (library.verified && !excludeBadges.verified) { badges.push(chalk.green('[verified] ')); } } if (library.visibility === 'private' && !excludeBadges.private) { badges.push(chalk.blue('[private] ')); } else { if (library.mine && !excludeBadges.mine) { badges.push(chalk.blue('[mine] ')); } } const badgesText = badges.join(''); const version = library.version; const defaultSentence = ''; const formatted = chalk.blue(library.name) + ' ' + version + ' ' + badgesText + chalk.grey(library.installs || 0) + ' ' + `${library.sentence || defaultSentence}`; return formatted; };