diff options
Diffstat (limited to 'src/general-util.js')
-rw-r--r-- | src/general-util.js | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/general-util.js b/src/general-util.js new file mode 100644 index 0000000..67f53e3 --- /dev/null +++ b/src/general-util.js @@ -0,0 +1,16 @@ +module.exports.showTrackProcessStatus = function( + total, doneCount, noLineBreak = false +) { + // Log a status line which tells how many tracks are processed and what + // percent is completed. (Uses non-specific language: it doesn't say + // "how many tracks downloaded" or "how many tracks processed", but + // rather, "how many tracks completed".) Pass noLineBreak = true to skip + // the \n character (you'll probably also want to log \r after). + + const percent = Math.trunc(doneCount / total * 10000) / 100 + process.stdout.write( + `\x1b[1m${percent}% completed ` + + `(${doneCount}/${total} tracks)\x1b[0m` + + (noLineBreak ? '' : '\n') + ) +} |