Skip to content

Commit

Permalink
Removed process piping support and made output inline only
Browse files Browse the repository at this point in the history
  • Loading branch information
MitchPierias committed Apr 25, 2019
1 parent 97d9625 commit dd0dc9a
Showing 1 changed file with 11 additions and 25 deletions.
36 changes: 11 additions & 25 deletions src/cli/logIndicator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,20 @@ 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 <github.com/MitchPierias>
* @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();
delete cache.spinner;
}
// Create and cache spinner
cache.spinner = ora({
text,
text:colors.white(text),
color: 'magenta'
}).start();
}
Expand All @@ -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;
}

/**
Expand Down

0 comments on commit dd0dc9a

Please sign in to comment.