Skip to content

Commit f2ac111

Browse files
authoredMar 19, 2023
Add spinners export to be able to access all available spinners (#222)
1 parent b4d9c06 commit f2ac111

File tree

5 files changed

+17
-5
lines changed

5 files changed

+17
-5
lines changed
 

‎index.d.ts

+2
Original file line numberDiff line numberDiff line change
@@ -306,3 +306,5 @@ export function oraPromise<T>(
306306
action: PromiseLike<T> | ((spinner: Ora) => PromiseLike<T>),
307307
options?: string | PromiseOptions<T>
308308
): Promise<T>;
309+
310+
export {default as spinners} from 'cli-spinners';

‎index.js

+2
Original file line numberDiff line numberDiff line change
@@ -378,3 +378,5 @@ export async function oraPromise(action, options) {
378378
throw error;
379379
}
380380
}
381+
382+
export {default as spinners} from 'cli-spinners';

‎index.test-d.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {PassThrough as PassThroughStream} from 'node:stream';
22
import {expectType} from 'tsd';
3-
import ora, {oraPromise} from './index.js';
3+
import cliSpinners from 'cli-spinners';
4+
import ora, {oraPromise, spinners} from './index.js';
45

56
const spinner = ora('Loading unicorns');
67
ora({text: 'Loading unicorns'});
@@ -68,3 +69,5 @@ void oraPromise(async spinner => {
6869
successText: result => `Resolved with number ${result}`,
6970
failText: 'bar',
7071
});
72+
73+
expectType<typeof cliSpinners>(spinners);

‎readme.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ Text or a function that returns text to display before the spinner. No prefix te
5555
Type: `string | object`\
5656
Default: `'dots'` <img src="screenshot-spinner.gif" width="14">
5757

58-
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.
58+
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.
5959

6060
Or an object like:
6161

@@ -268,6 +268,12 @@ The new text of the spinner when the promise is rejected.
268268

269269
Keeps the existing text if `undefined`.
270270

271+
### spinners
272+
273+
Type: `Record<string, Spinner>`
274+
275+
All [provided spinners](https://github.com/sindresorhus/cli-spinners/blob/main/spinners.json).
276+
271277
## FAQ
272278

273279
### How do I change the color of the text?

‎test.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ import getStream from 'get-stream';
44
import test from 'ava';
55
import stripAnsi from 'strip-ansi';
66
import TransformTTY from 'transform-tty';
7-
import cliSpinners from 'cli-spinners';
8-
import ora, {oraPromise} from './index.js';
7+
import ora, {oraPromise, spinners} from './index.js';
98

109
const spinnerCharacter = process.platform === 'win32' ? '-' : '⠋';
1110
const noop = () => {};
@@ -666,7 +665,7 @@ test('new clear method, stress test', t => {
666665
const randos = () => rAnDoMaNiMaLs(rando(5, 15), rando(25, 50));
667666

668667
const randomize = (s1, s2) => {
669-
const spnr = cliSpinners.random;
668+
const spnr = spinners.random;
670669
const txt = randos();
671670
const indent = rando(0, 15);
672671

0 commit comments

Comments
 (0)
Please sign in to comment.