UNPKG

@constructor-io/constructorio-connect-cli

Version:

CLI tool to enable users to interface with the Constructor Connect Ecosystem

31 lines (30 loc) 875 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.uxAction = uxAction; const nanospinner_1 = require("nanospinner"); function uxAction(title, func) { return function (...args) { const spinner = (0, nanospinner_1.createSpinner)(title).start(); let result; try { result = func(...args); } catch (error) { spinner.error({ text: title, mark: "❌" }); throw error; } if (result?.then) { result .then(() => { spinner.success({ text: title, mark: "✅" }); }) .catch(() => { spinner.error({ text: title, mark: "❌" }); }); } else { spinner.success({ text: title, mark: "✅" }); } return result; }; }