clearLeftovers

tcmts.cli.web.clearLeftovers · #4uhhn5ep · term · runs on the server

uses node:fs

Remove what processes that have ended left in dir: what's named with an ownId.

import { ownerGone } from "#codebase/tcmts/cli/web";
import fs from "node:fs";
import path from "node:path";

export function clearLeftovers(dir: string) {
  for (const e of fs.existsSync(dir) ? fs.readdirSync(dir) : [])
    if (ownerGone(e)) fs.rmSync(path.join(dir, e), { recursive: true, force: true });
}

uses

used by