Skip to content

Commit

Permalink
Add spinners export to be able to access all available spinners (#222)
Browse files Browse the repository at this point in the history
  • Loading branch information
tommy-mitchell committed Mar 19, 2023
1 parent b4d9c06 commit f2ac111
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 5 deletions.
2 changes: 2 additions & 0 deletions index.d.ts
Expand Up @@ -306,3 +306,5 @@ export function oraPromise<T>(
action: PromiseLike<T> | ((spinner: Ora) => PromiseLike<T>),
options?: string | PromiseOptions<T>
): Promise<T>;

export {default as spinners} from 'cli-spinners';
2 changes: 2 additions & 0 deletions index.js
Expand Up @@ -378,3 +378,5 @@ export async function oraPromise(action, options) {
throw error;
}
}

export {default as spinners} from 'cli-spinners';
5 changes: 4 additions & 1 deletion 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'});
Expand Down Expand Up @@ -68,3 +69,5 @@ void oraPromise(async spinner => {
successText: result => `Resolved with number ${result}`,
failText: 'bar',
});

expectType<typeof cliSpinners>(spinners);
8 changes: 7 additions & 1 deletion readme.md
Expand Up @@ -55,7 +55,7 @@ Text or a function that returns text to display before the spinner. No prefix te
Type: `string | object`\
Default: `'dots'` <img src="screenshot-spinner.gif" width="14">

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:

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

Keeps the existing text if `undefined`.

### spinners

Type: `Record<string, Spinner>`

All [provided spinners](https://github.com/sindresorhus/cli-spinners/blob/main/spinners.json).

## FAQ

### How do I change the color of the text?
Expand Down
5 changes: 2 additions & 3 deletions test.js
Expand Up @@ -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 = () => {};
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit f2ac111

Please sign in to comment.