INNER CODE UNIT · TypeScript
basename
modem-dev/hunk · packages/hunk-sapling/src/index.ts:33
function basename(path: string) {
return path.split(/[\\/]/).filter(Boolean).pop() ?? path;
}
/** Return whether a `.hg` directory belongs to Sapling rather than upstream Mercurial. */
function isSaplingHgRepo(hgDir: string) {
try {
return fs.readFileSync(join(hgDir, "requires"), "utf8").split("\n").includes("treestate");
} catch {
return false;
}
}
/** Walk upward to detect a Sapling workspace marker. `.sl` always matches;
* `.hg` only matches when `.hg/requires` contains `treestate` (Sapling-specific). */
function detectSlRepo(cwd: string) {
let current = resolve(cwd);
for (;;) {