function paintHelp(txt) { return colors.magenta(txt); //display the help text in a color }
const logGreen = (msg) => console.log(colors.green(msg))
const loadPackage = (moduleName, moduleAs, installPath) => { return new Promise((resolve, reject) => { try { const loadedPackage = require(packageLocation(moduleName, installPath)) console.log(colors.blue(`'${moduleName}' was already installed since before!`)) resolve({name: moduleName, package: loadedPackage, as: moduleAs}) } catch (err) { console.log(colors.yellow(`Couldn't find '${moduleName}' locally, gonna download it now`)) npmi({name: moduleName, path: installPath}, (err, result) => { if (err) { console.log(colors.red(err.message)) if (err.statusCode === 404) { throw new Error(`Could not find package ${moduleName}`) } if (err.code === npmi.LOAD_ERR) { throw new Error('npm load error') } if (err.code === npmi.INSTALL_ERR) { throw new Error('npm install error') } } const loadedPackage = require(packageLocation(moduleName, installPath)) resolve({name: moduleName, package: loadedPackage, as: moduleAs}) }) } }) }
const blockNumber = object[key] if (blockNumber === 0) { table.push([{colSpan:2,content:colors.green.bold("🏆 Genesis Block"), hAlign:'center'}]) } else { table.push([{colSpan:2,content:colors.green.bold(`⛓ Block #${object[key]}`), hAlign:'center'}]) obj[`⏮ ${colors.red('Previous Hash')}`] = object[key] } else if (key === 'timestamp') { obj[`📅 ${colors.red('Timestamp')}`] = new Date(object[key] * 1000).toUTCString() } else if (key === 'data') { obj[`📄 ${colors.red('Data')}`] = object[key] } else if (key === 'hash') { obj[`📛 ${colors.red('Hash')}`] = object[key] } else if (key === 'nonce') { obj[`🔨 ${colors.red('Nonce')}`] = object[key]
function myFormatter(options, params, payload){ // bar grows dynamically by current progrss - no whitespaces are added const bar = options.barCompleteString.substr(0, Math.round(params.progress*options.barsize)); // end value reached ? // change color to green when finished if (params.value >= params.total){ return '# ' + _colors.grey(payload.task) + ' ' + _colors.green(params.value + '/' + params.total) + ' --[' + bar + ']-- '; }else{ return '# ' + payload.task + ' ' + _colors.yellow(params.value + '/' + params.total) + ' --[' + bar + ']-- '; } }
// helper function to display preset function showPreset(name){ console.log(_colors.magenta('Preset: ' + name)); // create a new progress bar with preset var bar = new _progress.Bar({}, _progress.Presets[name] || _progress.Presets.legacy); bar.start(200, 0); // random value 1..200 bar.update(Math.floor((Math.random() * 200) + 1)); bar.stop(); console.log(''); }
const exit_error = (err) => { spinner.stop(); console.error(colors.red(`\n${err}`)); process.exit(); }
it('feel free to use colors in your content strings, column widths will be calculated correctly', function () { function makeTable() { let table = new Table({ colWidths: [5], style: { head: [], border: [] }, }); table.push([colors.red('hello')]); return table; } let expected = ['┌─────┐', '│ ' + colors.red('he') + '… │', '└─────┘']; return [makeTable, expected, 'truncation-with-colors']; });
/** * Initialize and start the bot. */ function start() { console.log(c.cyan("Carregando eventos...")); loadEvents("./events"); console.log(c.cyan("Carregando comandos...")); loadCommands("./commands"); console.log(c.cyan("Conectando o bot...")); client.login(process.env.CLIENT_TOKEN); client.mongoose.init(); }
it('should allow turning off aligning hash key values', () => { const input = { veryLargeParam: 'first string', param: 'second string' } const output = prettyoutput(input, { alignKeyValues: false }) output.should.equal([`${colors.green('veryLargeParam: ')}first string`, `${colors.green('param: ')}second string`, ''].join('\n')) })