Skip to content

Commit 92dae41

Browse files
committed
fix: Code Analyzer binary lookup for ReScript v12+
For v12+, rescript-tools.exe is at @rescript/{platform}-{arch}/bin/. Try this path first, then fall back to legacy paths.
1 parent 07d912f commit 92dae41

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
#### :bug: Bug fix
1616

17+
- Fix Code Analyzer binary lookup for ReScript v12+ projects.
1718
- Take namespace into account for incremental cleanup. https://github.com/rescript-lang/rescript-vscode/pull/1164
1819
- Potential race condition in incremental compilation. https://github.com/rescript-lang/rescript-vscode/pull/1167
1920
- Fix extension crash triggered by incremental compilation. https://github.com/rescript-lang/rescript-vscode/pull/1169

client/src/commands/code_analysis.ts

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as cp from "child_process";
2+
import * as fs from "fs";
23
import * as path from "path";
34
import {
45
window,
@@ -216,12 +217,27 @@ export const runCodeAnalysisWithReanalyze = (
216217
currentDocument.uri.fsPath,
217218
);
218219

219-
// This little weird lookup is because in the legacy setup reanalyze needs to be
220-
// run from the analysis binary, whereas in the new setup it's run from the tools
221-
// binary.
222-
let binaryPath =
223-
getBinaryPath("rescript-tools.exe", projectRootPath) ??
224-
getBinaryPath("rescript-editor-analysis.exe");
220+
// Try v12+ path first: @rescript/{platform}-{arch}/bin/rescript-tools.exe
221+
// Then fall back to legacy paths via getBinaryPath
222+
let binaryPath: string | null = null;
223+
if (projectRootPath != null) {
224+
const v12Path = path.join(
225+
projectRootPath,
226+
"node_modules",
227+
"@rescript",
228+
`${process.platform}-${process.arch}`,
229+
"bin",
230+
"rescript-tools.exe",
231+
);
232+
if (fs.existsSync(v12Path)) {
233+
binaryPath = v12Path;
234+
}
235+
}
236+
if (binaryPath == null) {
237+
binaryPath =
238+
getBinaryPath("rescript-tools.exe", projectRootPath) ??
239+
getBinaryPath("rescript-editor-analysis.exe", projectRootPath);
240+
}
225241

226242
if (binaryPath === null) {
227243
window.showErrorMessage("Binary executable not found.");

0 commit comments

Comments
 (0)