From f2ac111653ac2c8592371d6ea51c4fb33e4af4cb Mon Sep 17 00:00:00 2001 From: Tommy Date: Sun, 19 Mar 2023 05:10:50 -0500 Subject: [PATCH] Add `spinners` export to be able to access all available spinners (#222) --- index.d.ts | 2 ++ index.js | 2 ++ index.test-d.ts | 5 ++++- readme.md | 8 +++++++- test.js | 5 ++--- 5 files changed, 17 insertions(+), 5 deletions(-) diff --git a/index.d.ts b/index.d.ts index ff84da3..35000c8 100644 --- a/index.d.ts +++ b/index.d.ts @@ -306,3 +306,5 @@ export function oraPromise( action: PromiseLike | ((spinner: Ora) => PromiseLike), options?: string | PromiseOptions ): Promise; + +export {default as spinners} from 'cli-spinners'; diff --git a/index.js b/index.js index 0d951ad..f6e94b2 100644 --- a/index.js +++ b/index.js @@ -378,3 +378,5 @@ export async function oraPromise(action, options) { throw error; } } + +export {default as spinners} from 'cli-spinners'; diff --git a/index.test-d.ts b/index.test-d.ts index 5c129c0..7219e22 100644 --- a/index.test-d.ts +++ b/index.test-d.ts @@ -1,6 +1,7 @@ import {PassThrough as PassThroughStream} from 'node:stream'; import {expectType} from 'tsd'; -import ora, {oraPromise} from './index.js'; +import cliSpinners from 'cli-spinners'; +import ora, {oraPromise, spinners} from './index.js'; const spinner = ora('Loading unicorns'); ora({text: 'Loading unicorns'}); @@ -68,3 +69,5 @@ void oraPromise(async spinner => { successText: result => `Resolved with number ${result}`, failText: 'bar', }); + +expectType(spinners); diff --git a/readme.md b/readme.md index 727556f..311b898 100644 --- a/readme.md +++ b/readme.md @@ -55,7 +55,7 @@ Text or a function that returns text to display before the spinner. No prefix te Type: `string | object`\ Default: `'dots'` -Name of one of the [provided spinners](https://github.com/sindresorhus/cli-spinners/blob/main/spinners.json). See `example.js` in this repo if you want to test out different spinners. On Windows, it will always use the `line` spinner as the Windows command-line doesn't have proper Unicode support. +Name of one of the [provided spinners](#spinners). See `example.js` in this repo if you want to test out different spinners. On Windows, it will always use the `line` spinner as the Windows command-line doesn't have proper Unicode support. Or an object like: @@ -268,6 +268,12 @@ The new text of the spinner when the promise is rejected. Keeps the existing text if `undefined`. +### spinners + +Type: `Record` + +All [provided spinners](https://github.com/sindresorhus/cli-spinners/blob/main/spinners.json). + ## FAQ ### How do I change the color of the text? diff --git a/test.js b/test.js index c2a59a4..276bd5b 100644 --- a/test.js +++ b/test.js @@ -4,8 +4,7 @@ import getStream from 'get-stream'; import test from 'ava'; import stripAnsi from 'strip-ansi'; import TransformTTY from 'transform-tty'; -import cliSpinners from 'cli-spinners'; -import ora, {oraPromise} from './index.js'; +import ora, {oraPromise, spinners} from './index.js'; const spinnerCharacter = process.platform === 'win32' ? '-' : '⠋'; const noop = () => {}; @@ -666,7 +665,7 @@ test('new clear method, stress test', t => { const randos = () => rAnDoMaNiMaLs(rando(5, 15), rando(25, 50)); const randomize = (s1, s2) => { - const spnr = cliSpinners.random; + const spnr = spinners.random; const txt = randos(); const indent = rando(0, 15);