refactor(setup): reuse client registration file probes (#16855)

This commit is contained in:
Vincent Koc authored and GitHub committed 2026-12-05 06:42:36 +08:00
1 parent dd4ce1b2ad
commit bfecf4e00d
1 file changed
+6 -15
+6 -15
View File
@@ -28,6 +28,10 @@ import {
appendCallerPath,
hasParentTraversal,
} from "../filesystem/callerPath.js";
import {
isExecutableFileSync,
isRegularFileSync,
} from "../filesystem/regularFileProbe.js";
import { PRODUCT_IDENTITY } from "../identity.js";
import {
aubeShimLauncher,
@@ -293,14 +297,6 @@ const windowsReaCmdScript = (cmdPath: string): string | undefined => {
return joined;
};
const isRegularFile = (path: string): boolean => {
try {
return statSync(path).isFile();
} catch {
return false;
}
};
/**
* First PATH hit for a bare CLI name that is a regular file. A working-
* directory-dependent PATH entry reached before a hit keeps the result
@@ -318,7 +314,7 @@ const resolveBareCliOnPath = (
if (!search.ok) return "unknown";
for (const candidate of search.value) {
if (candidate.relativeEntry) return "unknown";
if (!isRegularFile(candidate.path)) continue;
if (!isRegularFileSync(candidate.path)) continue;
return candidate.path;
}
return undefined;
@@ -328,12 +324,7 @@ const resolveBareCliOnPath = (
unreadableWorkingDirectory: "as-written",
})) {
if (candidate.relativeEntry) return "unknown";
try {
accessSync(candidate.path, constants.X_OK);
} catch {
continue;
}
if (!isRegularFile(candidate.path)) continue;
if (!isExecutableFileSync(candidate.path)) continue;
return candidate.path;
}
return undefined;