Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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({