runAnimator (lib/terminal-spinner.js)

ECC · scripts/lib/terminal-spinner.js · javascript · MIT
cli

Terminal spinner utility for CLI progress indication.

// Source: https://github.com/affaan-m/ECC | License: MIT | Copyright 2026 Affaan Mustafa
// Provided via justclaw.it.com; keep this notice with the code.
'use strict';

const { spawn } = require('child_process');

const CLEAR_LINE = '\r\x1b[2K';
const FRAMES = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
const FRAME_INTERVAL_MS = 80;

function runAnimator(label, options = {}) {
  const output = options.output || process.stdout;
  const schedule = options.schedule || setInterval;
  const clearSchedule = options.clearSchedule || clearInterval;
  const onDisconnect = options.onDisconnect
    || (handler => process.on('disconnect', handler));
  const exit = options.exit || (code => process.exit(code));
  let frameIndex = 1;
  const timer = schedule(() => {
    output.write(`\r${FRAMES[

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key