From 6396c8eaf44d00963f362c000cdac03a04e72a9c Mon Sep 17 00:00:00 2001 From: Naomi Carrigan Date: Mon, 9 Dec 2024 07:57:50 -0800 Subject: [PATCH] feat: only run application in a screen environment --- src/index.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/index.ts b/src/index.ts index eb0449cd..0ecf53ec 100644 --- a/src/index.ts +++ b/src/index.ts @@ -15,9 +15,22 @@ import { barFormatter } from "./tools/barFormatter.js"; dotenv.config(); +const isInScreenEnvironment = () => { + return ( + process.env.STY !== undefined || + process.env.SCREEN !== undefined || + (process.env.TERM !== undefined && process.env.TERMCAP) + ); +}; + // Anonymous function for IIFE to allow async (async function () { console.info(chalk.green(`Hello! Launching email blast application.`)); + if (!isInScreenEnvironment()) { + throw new Error( + "You must run this script in a screen session to persist the process after closing the SSH connection." + ); + } /** * Begin by confirming the environment variables. */