How to use the cli-spinners.moon function in cli-spinners

To help you get started, we’ve selected a few cli-spinners examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github runtools / run / packages / common / src / index.js View on Github external
export async function task(message, successMessage, fn) {
  if (typeof successMessage === 'function') {
    fn = successMessage;
    successMessage = undefined;
  }

  const spinner = ora({
    text: truncate(message),
    spinner: cliSpinners.moon
  }).start();

  const currentTask = {
    setMessage(message) { spinner.text = truncate(message); },
    setSuccessMessage(message) { successMessage = message; }
  };

  try {
    const result = await fn(currentTask);
    spinner.stopAndPersist({
      text: successMessage,
      symbol: getSuccessSymbol() + ' '
    });
    return result;
  } catch (err) {
    spinner.stopAndPersist({