diff --git a/lib/renderers/cli.js b/lib/renderers/cli.js index 02fee627..d28e7128 100644 --- a/lib/renderers/cli.js +++ b/lib/renderers/cli.js @@ -2,7 +2,7 @@ var mout = require('mout'); var paddings = { tag: 10, - tagPlusLabel: 35 + tagPlusLabel: 31 }; var tagColors = { @@ -41,6 +41,14 @@ function renderEnd() { return ''; } +function renderCheckout(data) { + if (isCompact()) { + data.data = data.origin + '#' + data.data; + } + + return renderData(data); +} + // ------------------------- function empty() { @@ -51,6 +59,10 @@ function uncolor(str) { return str.replace(/\x1B\[\d+m/g, ''); } +function isCompact() { + return process.stdout.columns < 120; +} + function renderTagPlusLabel(data) { var label; var length; @@ -59,7 +71,7 @@ function renderTagPlusLabel(data) { var tagColor = tagColors[data.level] || tagColors._default; // If there's not enough space, print only the tag - if (process.stdout.columns < 120) { + if (isCompact()) { return mout.string.rpad(tag, paddings.tag)[tagColor]; } @@ -72,7 +84,7 @@ function renderTagPlusLabel(data) { nrSpaces = 1; } - return tag[tagColor] + mout.string.repeat(' ', nrSpaces) + label.green; + return label.green + mout.string.repeat(' ', nrSpaces) + tag[tagColor]; } // ------------------------- @@ -84,6 +96,7 @@ module.exports.colorful.tail = empty; module.exports.colorful.data = renderData; module.exports.colorful.error = renderError; module.exports.colorful.end = renderEnd; +module.exports.colorful.checkout = renderCheckout; // The colorless variant simply removes the colors from the colorful methods module.exports.colorless = mout.object.map(module.exports.colorful, function (fn) {