CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
sagemathinc

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/jupyter/util/fs.ts
Views: 687
1
import { homedir } from "os";
2
import { resolve } from "path";
3
4
export function getAbsolutePathFromHome(relativePath: string): string {
5
if (relativePath[0] == "/") {
6
// actually an absolute path.
7
return relativePath;
8
}
9
// NOTE: call homedir each time, since client code (e.g., for compute servers)
10
// may change the HOME env var dynamically at runtime.
11
return resolve(homedir(), relativePath);
12
}
13
14