Skip to content

Commit

Permalink
fix running reanalyze
Browse files Browse the repository at this point in the history
  • Loading branch information
zth committed Nov 11, 2024
1 parent 0131b59 commit 6938b33
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
9 changes: 8 additions & 1 deletion client/src/commands/code_analysis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,14 @@ export const runCodeAnalysisWithReanalyze = (
let projectRootPath: string | null = findProjectRootOfFileInDir(
currentDocument.uri.fsPath
);
let binaryPath = getBinaryPath("rescript-tools.exe", projectRootPath);

// This little weird lookup is because in the legacy setup reanalyze needs to be
// run from the analysis binary, whereas in the new setup it's run from the tools
// binary.
let binaryPath =
getBinaryPath("rescript-tools.exe", projectRootPath) ??
getBinaryPath("rescript-editor-analysis.exe");

if (binaryPath === null) {
window.showErrorMessage("Binary executable not found.");
return;
Expand Down
6 changes: 3 additions & 3 deletions client/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@ export const getLegacyBinaryProdPath = (b: binaryName) =>

export const getBinaryPath = (
binaryName: "rescript-editor-analysis.exe" | "rescript-tools.exe",
projectRootPath: string
projectRootPath: string | null = null
): string | null => {
const binaryFromCompilerPackage = path.join(
projectRootPath,
projectRootPath ?? "",
"node_modules",
"rescript",
platformDir,
binaryName
);

if (fs.existsSync(binaryFromCompilerPackage)) {
if (projectRootPath != null && fs.existsSync(binaryFromCompilerPackage)) {
return binaryFromCompilerPackage;
} else if (fs.existsSync(getLegacyBinaryDevPath(binaryName))) {
return getLegacyBinaryDevPath(binaryName);
Expand Down

0 comments on commit 6938b33

Please sign in to comment.