console.log('Начало работы...')
... функции
console.log('Работа завершена')
setTimeout(function f(percent) {
if (!process.stdout.isTTY) return;
if (percent > 100) {
process.stdout.write('\n');
return;
}
const FILL = 9608;
const SHADE = 9617;
const progressSize = process.stdout.columns / 2;
const fillSize = Math.ceil(progressSize * percent / 100);
const shadeSize = Math.floor(progressSize) - fillSize;
const fillText = String.fromCharCode(FILL).repeat(fillSize);
const shadeText = shadeSize > 0
? String.fromCharCode(SHADE).repeat(shadeSize)
: '';
process.stdout.clearLine();
process.stdout.write(`\r${fillText}${shadeText} ${percent}%`);
setTimeout(f, 250, percent + 1);
}, 100, 0);