From 22e5efbf156a192f52c5985d60b937edb19d941e Mon Sep 17 00:00:00 2001 From: IRONM00N <64110067+IRONM00N@users.noreply.github.com> Date: Mon, 14 Mar 2022 21:08:34 -0400 Subject: fix: check for TTY --- src/lib/utils/BushLogger.ts | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'src/lib/utils/BushLogger.ts') diff --git a/src/lib/utils/BushLogger.ts b/src/lib/utils/BushLogger.ts index 8556a77..caffecc 100644 --- a/src/lib/utils/BushLogger.ts +++ b/src/lib/utils/BushLogger.ts @@ -37,14 +37,21 @@ export class BushLogger { static #baseLog(type: 'stdout' | 'stderr' | 'log', content: string): void { const stream: NodeJS.WriteStream = type === 'stdout' || type === 'log' ? process.stdout : process.stderr; - stream.moveCursor(0, -1); - stream.write('\n'); - stream.clearLine(0); - // eslint-disable-next-line prefer-rest-params - if (type === 'log') console.log([...arguments].slice(1)); - else stream.write(`${content}\n`); - stream.moveCursor(0, typeof content === 'string' ? content.split('\n').length : 1); - if (!replGone) REPL.displayPrompt(true); + if (stream.isTTY) { + stream.moveCursor(0, -1); + stream.write('\n'); + stream.clearLine(0); + // eslint-disable-next-line prefer-rest-params + if (type === 'log') console.log([...arguments].slice(1)); + else stream.write(`${content}\n`); + stream.moveCursor(0, typeof content === 'string' ? content.split('\n').length : 1); + if (!replGone) REPL.displayPrompt(true); + } else { + // eslint-disable-next-line prefer-rest-params + if (type === 'log' || type === 'stdout') console.log([...arguments].slice(1)); + // eslint-disable-next-line prefer-rest-params + else console.error([...arguments].slice(1)); + } } public static raw(...content: any[]) { -- cgit