From a08895f62322ef05bbbfb98c5e776d6950f965a8 Mon Sep 17 00:00:00 2001 From: Martin Lingstuyl Date: Wed, 27 Sep 2023 09:29:32 +0200 Subject: [PATCH] Makes spinner stream configurable by errorOutput. Closes #5521 --- src/Auth.ts | 2 +- src/cli/Cli.ts | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Auth.ts b/src/Auth.ts index c220c6caf89..18e66b9045d 100644 --- a/src/Auth.ts +++ b/src/Auth.ts @@ -423,7 +423,7 @@ export class Auth { const cli = Cli.getInstance(); cli.spinner.text = response.message; cli.spinner.spinner = { - frames: ['🌶️ '] + frames: ['🌶️'] }; // don't show spinner if running tests diff --git a/src/cli/Cli.ts b/src/cli/Cli.ts index f3b44052acf..9f69527bb1c 100644 --- a/src/cli/Cli.ts +++ b/src/cli/Cli.ts @@ -1,7 +1,7 @@ import Configstore from 'configstore'; import fs from 'fs'; import minimist from 'minimist'; -import ora from 'ora'; +import ora, { Options, Ora } from 'ora'; import os from 'os'; import path from 'path'; import { pathToFileURL } from 'url'; @@ -41,7 +41,7 @@ export class Cli { private static instance: Cli; private static defaultHelpMode = 'options'; public static helpModes: string[] = ['options', 'examples', 'remarks', 'response', 'full']; - public spinner = ora('Running command...'); + public spinner: Ora; private _config: Configstore | undefined; public get config(): Configstore { @@ -62,8 +62,13 @@ export class Cli { } } - // eslint-disable-next-line @typescript-eslint/no-empty-function private constructor() { + const options: Options = { + text: 'Running command...', + /* c8 ignore next 1 */ + stream: this.getSettingWithDefaultValue('errorOutput', 'stderr') === 'stderr' ? process.stderr : process.stdout + }; + this.spinner = ora(options); } public static getInstance(): Cli {