diff --git a/src/float.ts b/src/float.ts index 083641f..328467c 100644 --- a/src/float.ts +++ b/src/float.ts @@ -113,7 +113,7 @@ process.on("SIGTERM", process.exit); const waitLoop = async () => { await downloadNewVideos(); setTimeout(waitLoop, 5 * 60 * 1000); - console.log("[" + new Date().toLocaleTimeString() + "]" + " Checking for new videos in 5 minutes..."); + console.log(`${args.headless ? `[${new Date().toLocaleString()}]` : ""} Checking for new videos in 5 minutes...`); }; waitLoop(); } diff --git a/src/lib/helpers/index.ts b/src/lib/helpers/index.ts index aed8370..e0c09cc 100644 --- a/src/lib/helpers/index.ts +++ b/src/lib/helpers/index.ts @@ -74,6 +74,8 @@ recursiveUpdate(settings, env, { setUndefined: false, setDefined: true }); export const args = { ...argv, ...env }; +// eslint-disable-next-line no-control-regex +const headlessStdoutRegex = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g; // Override stdout if headless to not include formatting tags if (args.headless === true) { const originalStdoutWrite = process.stdout.write.bind(process.stdout); @@ -81,7 +83,7 @@ if (args.headless === true) { process.stdout.write = ((...params: StdoutArgs) => { // eslint-disable-next-line no-control-regex - if (typeof params[0] === "string") params[0] = params[0].replace(/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, ""); + if (typeof params[0] === "string") params[0] = `[${new Date().toLocaleString()}] ${params[0].replace(headlessStdoutRegex, "")}`; return originalStdoutWrite(...params); }) as typeof process.stdout.write; }