diff options
author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2022-03-14 21:08:34 -0400 |
---|---|---|
committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2022-03-14 21:08:34 -0400 |
commit | 22e5efbf156a192f52c5985d60b937edb19d941e (patch) | |
tree | 1ec147d03a31eda3685c09c5d44b503638cdbb76 | |
parent | 7cb1add2a8d5febb0a3a5a90d7c4af461780bfe1 (diff) | |
download | tanzanite-22e5efbf156a192f52c5985d60b937edb19d941e.tar.gz tanzanite-22e5efbf156a192f52c5985d60b937edb19d941e.tar.bz2 tanzanite-22e5efbf156a192f52c5985d60b937edb19d941e.zip |
fix: check for TTY
-rw-r--r-- | src/lib/utils/BushLogger.ts | 23 |
1 files changed, 15 insertions, 8 deletions
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[]) { |