UNPKG

@iexec/iapp

Version:

A CLI to guide you through the process of building an iExec iApp

44 lines 1.18 kB
import ora from 'ora'; import prompts from 'prompts'; import { AbortError } from '../utils/errors.js'; export const getSpinner = () => { const spinner = ora({ isEnabled: !process.env.DEBUG }); // disable spinner when DEBUG is enabled const log = (msg) => { const { isSpinning } = spinner; if (isSpinning) { spinner.stop(); } // eslint-disable-next-line no-console console.log(msg); if (isSpinning) { spinner.start(); } }; const newLine = () => log(''); const reset = () => { spinner.text = ''; spinner.stop(); }; const prompt = async (questions) => { const { isSpinning } = spinner; if (isSpinning) { spinner.stop(); } const res = await prompts(questions, { onCancel: () => { throw new AbortError('Operation cancelled'); }, }); if (isSpinning) { spinner.start(); } return res; }; return Object.assign(spinner, { reset, log, newLine, prompt, }); }; //# sourceMappingURL=spinner.js.map