1import { homedir } from "os"; 2import { resolve } from "path"; 3 4export 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