Skip to content

Commit

Permalink
added support for tty or non tty logging of downloading
Browse files Browse the repository at this point in the history
  • Loading branch information
jack committed May 14, 2021
1 parent 7a060ba commit 87738ab
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/downloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ const downloader = async (youtubeLink, output, spinner) => {
download.on('progress', (_, downloaded, total) => {
const toBeDownloadedMb = (downloaded / 1024 / 1024).toFixed(2);
const downloadedMb = (total / 1024 / 1024).toFixed(2);
if (toBeDownloadedMb % 1 == 0 || toBeDownloadedMb == downloadedMb) {
const isTTY = process.stdout.isTTY;
if (isTTY) {
spinner.text =
`Downloaded ${toBeDownloadedMb}/${downloadedMb} MB`;
}
else if (toBeDownloadedMb % 1 == 0 || toBeDownloadedMb == downloadedMb) {
spinner.info(
`Downloaded ${toBeDownloadedMb}/${downloadedMb} MB`,
);
Expand Down

0 comments on commit 87738ab

Please sign in to comment.