Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

687 B
Raw Blame
import fs from "fs";

import { shell } from "../../../cypress-runner-utils";

export function setupAppCleanup({
  rootPath,
  env,
  appDownCommand,
  cleanupAppDir,
}: {
  rootPath: string;
  env: Record<string, string | number | undefined>;
  appDownCommand: string;
  cleanupAppDir: boolean;
}) {
  if (!process.env.CI) {
    ["exit", "SIGINT", "SIGTERM", "uncaughtException"].forEach((signal) => {
      process.on(signal, () => {
        console.log(`Parent received ${signal}, stopping app...`);

        shell(appDownCommand, { cwd: rootPath, env });

        if (cleanupAppDir) {
          fs.rmSync(rootPath, { recursive: true, force: true });
        }
      });
    });
  }
}