UNPKG

@gameroom/cli

Version:

A command line tool for Gameroom

36 lines (34 loc) 993 B
const markup = require('data-markup'), cosmetic = require('cosmetic') module.exports = (data) => { let output if (!process.stdout.isTTY) { output = JSON.stringify(data, null, 2) } else { output = markup(data, { translations: { created_at: (s) => s && s.toDate ? s.toDate() : s, updated_at: (s) => s && s.toDate ? s.toDate() : s, started_at: (s) => s.toDate(), ended_at: (s) => s.toDate(), audited_at: (s) => s != 0 && s.toDate ? s.toDate() : null, started_correction: (s) => s.toDate(), ended_correction: (s) => s.toDate(), color: (c) => c.toString(), // rank: (n) => { // if (n < 0) { // return `low` // } else if (n > 0) { // return 'high' // } else { // return 'medium' // } // } }, styles: { date: (d) => cosmetic.magenta(`${d.toLocaleString()}`) } }) } console.log(output) }