# @trufflesuite/spinnies

> Create and manage multiple spinners in command-line interface programs

Latest version **0.1.1** (published 2022-08-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install @trufflesuite/spinnies
pnpm add @trufflesuite/spinnies
yarn add @trufflesuite/spinnies
bun add @trufflesuite/spinnies
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2022-08-05 |
| First published | 2022-04-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 50.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Maintainers | sukanyaparashar, cliffoo, benjamincburns, jeff.smale, kevinbluer, tenthirtyone, lsqproduction, kevinweaver, leeftk, gnidan, davidmurdoch, eggplantzzz, fainashalts, haltman, rkalis, cds-amal, micaiahreid |
| Keywords | node, nodejs, node.js, multiple, multi, multispinner, spinner, spinners, loadre, loading, loading-bar, cli, console, command-line, command, terminal |

## Links

- npm: https://www.npmjs.com/package/@trufflesuite/spinnies
- Repository: https://github.com/trufflesuite/spinnies
- Homepage: https://github.com/trufflesuite/spinnies#readme
- Issues: https://github.com/trufflesuite/spinnies/issues
- npm.io page: https://npm.io/package/@trufflesuite/spinnies

## Dependencies (3)

- [chalk](https://npm.io/package/chalk.md) ^4.1.2
- [cli-cursor](https://npm.io/package/cli-cursor.md) ^3.1.0
- [strip-ansi](https://npm.io/package/strip-ansi.md) ^6.0.0

## Alternatives

- [@salesforce/cli](https://npm.io/package/@salesforce/cli.md) — 389.7K weekly downloads
- [@mintlify/cli](https://npm.io/package/@mintlify/cli.md) — 208.9K weekly downloads
- [@grafana/e2e-selectors](https://npm.io/package/@grafana/e2e-selectors.md) — 128.7K weekly downloads
- [mintlify](https://npm.io/package/mintlify.md) — 112.0K weekly downloads
- [@intlayer/cli](https://npm.io/package/@intlayer/cli.md) — 22.8K weekly downloads

## Recent versions

- 0.1.1 (latest) — 2022-08-05
- 0.1.0 — 2022-04-13

## README

# ![spin](https://i.ibb.co/4M0J13j/spin.png) Spinnies ![spin](https://i.ibb.co/4M0J13j/spin.png)
> Maintained by the Truffle team, originally forked from
> [jcarpanelli/spinnies](https://github.com/jcarpanelli/spinnies)

> Node.js module to create and manage multiple spinners in command-line interface programs


[![npm](https://img.shields.io/npm/v/spinnies.svg)](https://www.npmjs.com/package/@trufflesuite/spinnies)
[![standard-readme compliant](https://img.shields.io/badge/readme%20style-standard-brightgreen.svg)](https://github.com/RichardLitt/standard-readme)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

<p align="center"> <br> <img src='https://s3.us-west-2.amazonaws.com/jcarpanelli/termtosvg_zb90005u.svg' title='' /> </p>


## Installation

```
$ npm i spinnies
```

## Usage & Example

```js
const spinnies = new Spinnies();

spinnies.add('spinner-1', { text: 'I am a spinner' });
spinnies.add('spinner-2', { text: 'I am another spinner' });

setTimeout(() => {
  spinnies.succeed('spinner-1', { text: 'Success!' });
  spinnies.fail('spinner-2', { text: 'Fail :(' });
}, 2000);
```

## API

This library follows a **non-error-throwing** philosophy. If you provide an invalid option or an invalid value for a valid option *it will be ignored*.

### Initialization:

#### new Spinnies([options])

Parameters
- **options** - `object`:
  - **color** - `string`: Any valid [chalk color](https://github.com/chalk/chalk#colors). The default value is `white`.
  - **succeedColor** - `string`: Any valid [chalk color](https://github.com/chalk/chalk#colors). The default value is `green`.
  - **failColor** - `string`: Any valid [chalk color](https://github.com/chalk/chalk#colors). The default value is `red`.
  - **spinnerColor** - `string`: Any valid [chalk color](https://github.com/chalk/chalk#colors). The default value is `greenBright`.
  - **succeedPrefix** - `string`: The default value is ✓.
  - **failPrefix**- `string`: The default value is ✖.
  - **spinner**- `object`:
    - **interval** - `number`
    - **frames** - `string[]`

    You can see the already provided spinner [here](https://github.com/jcarpanelli/spinnies/blob/master/spinners.json).
  - **disableSpins** - `boolean`: Disable spins (will still print raw messages).

*Note: If you are working in any `win32` platform, the default spin animation will be overriden. You can get rid of this defining a different spinner animation manually, or by using the integrated VSCode terminal or Windows Terminal.*

Example:

```js
const spinner = { interval: 80, frames: ['🍇', '🍈', '🍉', '🍋'] }
const spinnies = new Spinnies({ color: 'blue', succeedColor: 'green', spinner });
```

### Instance methods:

#### add(name, [options])

Adds a new spinner with the given name.

Parameters:
- **name** - `string`: spinner reference name.
- **options** - `object`:
  - **text**: - `string`: Optional text to show in the spinner. If none is provided, the `name` field will be shown.
  - **indent**: - `number`: Optional, indent the spinner with the given number of spaces.
  - **status** - `string`: Initial status of the spinner. Valid statuses are: `succeed`, `fail`, `spinning`, `non-spinnable`and `stopped`.
  - **color** - `string`: Any valid [chalk color](https://github.com/chalk/chalk#colors).
  - **succeedColor** - `string`: Any valid [chalk color](https://github.com/chalk/chalk#colors).
  - **failColor** - `string`: Any valid [chalk color](https://github.com/chalk/chalk#colors).

Return value: Returns the spinner's options.

Example:

```js
const spinnies = new Spinnies();
spinnies.add('spinner-1');
spinnies.add('another-spinner', { text: 'Hello, I am a spinner!', color: 'greenBright' });

```

#### pick(name)
Picks a spinner.

Parameters:
- **name** - `string`: spinner reference name.

Return value: Returns the spinner's options.

#### remove(name)
Removes a spinner.

Parameters:
- **name** - `string`: spinner reference name.

Return value: Returns the spinner's options.

#### update(name, [options])

Updates the spinner with name `name` with the provided options.

Parameters:
- **name** - `string`: spinner reference name.
- **options** - `object`:
  - **text**: - `string`: Optional text to show in the spinner. If none is provided, the `name` field will be shown.
  - **status** - `string`: New status of the spinner. Valid statuses are: `succeed`, `fail`, `spinning`, `non-spinnable`and `stopped`.
  - **color** - `string`: Any valid [chalk color](https://github.com/chalk/chalk#colors).
  - **succeedColor** - `string`: Any valid [chalk color](https://github.com/chalk/chalk#colors).
  - **failColor** - `string`: Any valid [chalk color](https://github.com/chalk/chalk#colors).

Return value: Returns the spinner's options.

Example:

```js
const spinnies = new Spinnies();
spinnies.add('spinner-1', { text: 'Hello! I am the initial text', color: 'green' });
// some code
spinnies.update('spinner-1', { text: 'Hello, I am an updated text!', color: 'blue' });

```

#### succeed(name, [options])

Sets the specified spinner status as `succeed`.

Parameters:
- **name** - `string`: spinner reference name.
- **options** - `object`:
  - **text**: - `string`: Optional text to show in the spinner. If none is provided, the `name` field will be shown.
  - **succeedColor** - `string`: Any valid [chalk color](https://github.com/chalk/chalk#colors).

Return value: Returns the spinner's options.

Example:

```js
const spinnies = new Spinnies();
spinnies.add('spinner-1', { text: 'Hello! I am the initial text', color: 'green' });
// some code
spinnies.succeed('spinner-1', { text: 'Success!', successColor: 'greenBright' });

```

#### fail(name, [options])

Sets the specified spinner status as `fail`.

Parameters:
- **name** - `string`: spinner reference name.
- **options** - `object`:
  - **text**: - `string`: Optional text to show in the spinner. If none is provided, the `name` field will be shown.
  - **failColor** - `string`: Any valid [chalk color](https://github.com/chalk/chalk#colors).

Return value: Returns the spinner's options.

Example:

```js
const spinnies = new Spinnies();
spinnies.add('spinner-1', { text: 'Hello! I am the initial text', color: 'green' });
// some code
spinnies.fail('spinner-1', { text: 'I failed', failColor: 'redBright' });

```

#### stopAll([status])

Stops the spinners and sets the non-succeeded and non-failed ones to the provided status, which can be `succeed`, `fail` or `stopped`. You can see an example [here](https://github.com/jcarpanelli/spinnies/blob/master/examples/demo-stop-all.js).

#### hasActiveSpinners()
Return value: returns `false` if all spinners have succeeded, failed or have been stopped.


## Contribute

Star it, fork it, improve it, PR it! :raised_hands:.


## Acknowledgements

Thanks to [chalk](https://github.com/chalk/chalk) for helping making this lib colorful :rainbow: and to [ora](https://github.com/sindresorhus/ora) which was a great inspiration :unicorn:.

## License

[MIT](https://github.com/jcarpanelli/spinnies/blob/master/LICENSE)

---
_Source: https://npm.io/package/@trufflesuite/spinnies · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
