From 43053c6088b257b818268d49dbb790345abd5bca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre-Yves=20G=C3=A9rardy?= Date: Wed, 9 May 2018 07:58:47 +0200 Subject: [PATCH] [ospec] don't output colors when pipe or file redirection is used (#2143) --- ospec/change-log.md | 3 ++- ospec/ospec.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ospec/change-log.md b/ospec/change-log.md index ae7d662a..f691399c 100644 --- a/ospec/change-log.md +++ b/ospec/change-log.md @@ -8,9 +8,10 @@ ## 2.0.0 _2018-05-xx_ +- In Node.js, ospec only uses colors when the output is sent to a terminal ([#2143](https://github.com/MithrilJS/mithril.js/pull/2143)) - the CLI runner now accepts globs as arguments ([#2141](https://github.com/MithrilJS/mithril.js/pull/2141), [@maranomynet](https://github.com/maranomynet)) - Added support for custom reporters ([#2020](https://github.com/MithrilJS/mithril.js/pull/2020)) -- Make Ospec more [Flems](https://flems.io)-friendly ([#2034](https://github.com/MithrilJS/mithril.js/pull/2034)) +- Make ospec more [Flems](https://flems.io)-friendly ([#2034](https://github.com/MithrilJS/mithril.js/pull/2034)) - Works either as a global or in CommonJS environments - the o.run() report is always printed asynchronously (it could be synchronous before if none of the tests were async). - Properly point to the assertion location of async errors [#2036](https://github.com/MithrilJS/mithril.js/issues/2036) diff --git a/ospec/ospec.js b/ospec/ospec.js index c0bf2b60..f13b1ed0 100644 --- a/ospec/ospec.js +++ b/ospec/ospec.js @@ -259,7 +259,7 @@ else window.o = m() try {return JSON.stringify(value)} catch (e) {return String(value)} } function highlight(message) { - return hasProcess ? "\x1b[31m" + message + "\x1b[0m" : "%c" + message + "%c " + return hasProcess ? (process.stdout.isTTY ? "\x1b[31m" + message + "\x1b[0m" : message) : "%c" + message + "%c " } o.report = function (results) {