(title, fn)
| 1 | import { styleText } from 'node:util'; |
| 2 | |
| 3 | export async function runTask(title, fn) { |
| 4 | process.stdout.write(styleText('yellow', `◌ ${title}…\n`)); |
| 5 | try { |
| 6 | await fn(); |
| 7 | process.stdout.write(`\x1b[1A\x1b[2K${styleText('green', `✔ ${title}`)}\n`); |
| 8 | } catch (error) { |
| 9 | process.stdout.write(`\x1b[1A\x1b[2K${styleText('red', `✖ ${title}`)}\n`); |
| 10 | throw error; |
| 11 | } |
| 12 | } |