From 93f8d1a6b90dd61d55b3f082a18a37979761a1e9 Mon Sep 17 00:00:00 2001 From: Joe Hildebrand Date: Wed, 20 Jul 2022 15:43:23 -0600 Subject: [PATCH] Fixes #315. Check isTTY for all output before using colors. --- bin/peggy-cli.js | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/bin/peggy-cli.js b/bin/peggy-cli.js index bbf8b7c7..7234ddf3 100644 --- a/bin/peggy-cli.js +++ b/bin/peggy-cli.js @@ -84,7 +84,6 @@ class PeggyCLI extends Command { /** @type {peggy.BuildOptionsBase} */ this.argv = {}; - this.colors = this.std.err.isTTY; /** @type {string?} */ this.inputFile = null; /** @type {string?} */ @@ -386,7 +385,7 @@ class PeggyCLI extends Command { print(stream, ...args) { stream.write(util.formatWithOptions({ - colors: this.colors, + colors: stream.isTTY, depth: Infinity, maxArrayLength: Infinity, maxStringLength: Infinity, @@ -611,12 +610,7 @@ class PeggyCLI extends Command { opts.startRule = this.progOptions.startRule; } const results = exec.parse(this.testText, opts); - this.print(this.std.out, util.inspect(results, { - depth: Infinity, - colors: this.colors, - maxArrayLength: Infinity, - maxStringLength: Infinity, - })); + this.print(this.std.out, "%O", results); } }