From c0f0ddebc5635e0c9b162cadecab8760c4b00e17 Mon Sep 17 00:00:00 2001 From: Joshua Pohl Date: Fri, 22 Jan 2021 08:27:14 -0600 Subject: [PATCH] fix: disable download progress logging in non-TTY envs --- bin/util.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/bin/util.js b/bin/util.js index 3c0e0d9..b24af3f 100644 --- a/bin/util.js +++ b/bin/util.js @@ -189,6 +189,14 @@ let getImageUrl = ({ image, itunes }) => { let BYTES_IN_MB = 1000000; let printProgress = ({ percent, total, transferred }) => { + if (!process.stdout.isTTY) { + /* + Non-TTY environments do not have access to `stdout.clearLine` and + `stdout.cursorTo`. Skip download progress logging in these environments. + */ + return; + } + let line = "downloading..."; let percentRounded = (percent * 100).toFixed(2);