UNPKG

askeroo

Version:

A modern CLI prompt library with flow control, history navigation, and conditional prompts

43 lines 1.27 kB
#!/usr/bin/env node import { ask, spinner } from "../src/index.js"; function sleep(ms) { return new Promise((resolve) => setTimeout(resolve, ms)); } const flow = async () => { // Example 1: Spinner that hides on completion (no delay - skips stopped state) const job1 = await spinner("Downloading file...", { style: { color: "cyan", }, hideOnCompletion: true, }); await sleep(500); await job1.start(); await sleep(2000); await job1.stop("Downloaded!", { color: "green" }); // Disappears immediately without showing stopped state // Example 2: Another spinner that shows after completion const job2 = await spinner("Installing packages...", { style: { color: "blue", }, hideOnCompletion: false, // Default behavior }); await job2.start(); await sleep(2000); await job2.stop("Installed!", { color: "green" }); // This spinner remains visible await sleep(1000); return "All tasks completed!"; }; (async () => { try { const result = await ask(flow); console.log(result); } catch (error) { console.error("Error:", error); process.exit(1); } })(); //# sourceMappingURL=spinner-hide.js.map