UNPKG

@cocalc/project

Version:
26 lines 1.12 kB
"use strict"; /* * This file is part of CoCalc: Copyright © 2020 Sagemath, Inc. * License: AGPLv3 s.t. "Commons Clause" – see LICENSE.md for details */ Object.defineProperty(exports, "__esModule", { value: true }); exports.realpath = void 0; // path is assumed relative to the HOME directory // return value is also relative to HOME directory -- if it is // a symlink to something outside of the HOME directory, we just // return the input! This is used for sync so this is the best // we can do for now (see https://github.com/sagemathinc/cocalc/issues/4732) const fs_1 = require("fs"); const awaiting_1 = require("awaiting"); // SMC_LOCAL_HUB_HOME is used for developing cocalc inside cocalc... const HOME = process.env.SMC_LOCAL_HUB_HOME ?? process.env.HOME; async function realpath(path) { const fullpath = HOME + "/" + path; const rpath = await (0, awaiting_1.callback)(fs_1.realpath, fullpath); if (rpath == fullpath || !rpath.startsWith(HOME + "/")) { return path; } return rpath.slice((HOME + "/").length); } exports.realpath = realpath; //# sourceMappingURL=realpath.js.map