From 5a72979460996c724463b30988d16bd96025237d Mon Sep 17 00:00:00 2001 From: Max Satula Date: Thu, 9 Jan 2020 15:46:44 -0500 Subject: [PATCH] Force colorize only if `{ force: true }` is set Closes #60 --- colorize.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/colorize.js b/colorize.js index ba6860e..3c86aff 100644 --- a/colorize.js +++ b/colorize.js @@ -3,11 +3,6 @@ const colors = require('colors/safe'); const { LEVEL, MESSAGE } = require('triple-beam'); -// -// Fix colors not appearing in non-tty environments -// -colors.enabled = true; - /** * @property {RegExp} hasSpace * Simple regex to check for presence of spaces. @@ -24,6 +19,13 @@ class Colorizer { this.addColors(opts.colors); } + // + // Fix colors not appearing in non-tty environments + // + if (opts.force) { + colors.enabled = true; + } + this.options = opts; }