Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export cliSpinners as spinners #222

Merged
merged 2 commits into from
Mar 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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