'use strict';

const enabled = process.stdout.isTTY;

function wrap(code, text) {
  if (!enabled) return String(text);
  return `\x1b[${code}m${text}\x1b[0m`;
}

module.exports = {
  enabled,
  blue: (t) => wrap('34', t),
  cyan: (t) => wrap('36', t),
  gray: (t) => wrap('90', t),
  red: (t) => wrap('31', t),
  green: (t) => wrap('32', t),
  dim: (t) => wrap('2', t),
  bold: (t) => wrap('1', t),
  invert: (t) => wrap('7', t),
  reset: enabled ? '\x1b[0m' : '',
};
