Run multiple CLI spinners at the same time. Each Spinner has its own text and
state, while a shared renderer keeps active spinners aligned in the terminal.
Spinner animations come from cli-spinners. The API is
inspired by Ora, with support for concurrent asynchronous work.
- Node.js v22 or higher
This package is available in the Node Package Repository and can be easily installed with npm or yarn.
$ npm i @topcli/spinner
# or
$ yarn add @topcli/spinnerStart each spinner independently, then wait for the work to settle:
import * as timers from "node:timers/promises";
import { Spinner } from "@topcli/spinner";
async function runTask(label, shouldFail = false) {
const spinner = new Spinner().start(label);
await timers.setTimeout(1_000);
spinner.text = `${label}: still working`;
await timers.setTimeout(1_000);
if (shouldFail) {
spinner.failed(`${label}: failed`);
}
else {
spinner.succeed(`${label}: done in ${spinner.elapsedTime.toFixed(0)}ms`);
}
}
await Promise.allSettled([
runTask("Build"),
runTask("Test"),
runTask("Deploy", true)
]);Tip
Set verbose: false to suppress spinner output when your CLI is used as an
API.
Spinner: create, update and settle one spinner.computeWithSpinner: run an asynchronous operation with spinner lifecycle handling.
Thanks goes to these wonderful people (emoji key):
Gentilhomme 💻 📖 👀 🛡️ 🐛 |
Alexandre Malaj 💻 📖 🐛 |
PierreDemailly 💻 🚧 |
Ben 🐛 |
Clement Gombauld 💻 👀 |
MIT