From dd0dc9aad60900b3a36b0ed186329eb901eda0f5 Mon Sep 17 00:00:00 2001 From: Mitch Pierias Date: Thu, 25 Apr 2019 22:49:58 +1000 Subject: [PATCH] Removed process piping support and made output inline only --- src/cli/logIndicator.ts | 36 +++++++++++------------------------- 1 file changed, 11 insertions(+), 25 deletions(-) diff --git a/src/cli/logIndicator.ts b/src/cli/logIndicator.ts index 6ca2276..4308938 100644 --- a/src/cli/logIndicator.ts +++ b/src/cli/logIndicator.ts @@ -4,20 +4,12 @@ import * as colors from 'colors'; /** Holds spinner instances */ const cache:{ spinner?:Ora } = {}; -/** Alters output based on the process being piped */ -const isTTY:boolean = process.env.CI ? false : process.stdout.isTTY!; - /** * Creates a new spinner instance with the specified message * @author Mitch Pierias * @param text Output display message */ export const create = (text:string) => { - // Handle process piping - if (!isTTY) { - console.log(`lamington - ${text}`); - return; - } // Cleanup existing spinner if (cache.spinner) { cache.spinner.succeed(); @@ -25,7 +17,7 @@ export const create = (text:string) => { } // Create and cache spinner cache.spinner = ora({ - text, + text:colors.white(text), color: 'magenta' }).start(); } @@ -36,23 +28,17 @@ export const create = (text:string) => { * @param message Output message * @param isError Renders output as error toggle */ -export const end = (message?:string, isError:boolean = false) => { - // Handle process piping - if (!isTTY) { - console.log(`create-react-app - ${message}`); - return; - } - // Handle existing spinner - if (cache.spinner) { - (isError ? cache.spinner.fail() : cache.spinner.succeed()); - delete cache.spinner; +export const end = (message:string = '', isError:boolean = false) => { + // Check spinner reference + if (!cache.spinner) return; + // Handle output + if (isError) { + cache.spinner.fail(colors.grey(message)) + } else { + cache.spinner.succeed(colors.grey(message)) } - // Output closure message - if (!message || message == '') return; - const prefix = isError ? colors.red('ERROR:') : colors.green('DONE!'); - console.log(` -${prefix} ${message} -`); + // Clear spinner reference + delete cache.spinner; } /**