currentDirectory

tcmts.core.program.currentDirectory · #pb2qzs75 · term · runs on the server

uses node:fs

Where tcm runs, as it was reached: the shell's PWD when it's this directory (through a link, say), so paths shown from here are from where the files are named, not from where they really are.

import fs from "node:fs";

export function currentDirectory(): string {
  const cwd = process.cwd();
  const pwd = process.env.PWD;
  try {
    if (pwd && pwd !== cwd && fs.realpathSync(pwd) === fs.realpathSync(cwd)) return pwd;
  } catch {}
  return cwd;
}

used by