Skip to content

Commit 6938b33

Browse files
committed
fix running reanalyze
1 parent 0131b59 commit 6938b33

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

client/src/commands/code_analysis.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,14 @@ export const runCodeAnalysisWithReanalyze = (
211211
let projectRootPath: string | null = findProjectRootOfFileInDir(
212212
currentDocument.uri.fsPath
213213
);
214-
let binaryPath = getBinaryPath("rescript-tools.exe", projectRootPath);
214+
215+
// This little weird lookup is because in the legacy setup reanalyze needs to be
216+
// run from the analysis binary, whereas in the new setup it's run from the tools
217+
// binary.
218+
let binaryPath =
219+
getBinaryPath("rescript-tools.exe", projectRootPath) ??
220+
getBinaryPath("rescript-editor-analysis.exe");
221+
215222
if (binaryPath === null) {
216223
window.showErrorMessage("Binary executable not found.");
217224
return;

client/src/utils.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,17 @@ export const getLegacyBinaryProdPath = (b: binaryName) =>
2929

3030
export const getBinaryPath = (
3131
binaryName: "rescript-editor-analysis.exe" | "rescript-tools.exe",
32-
projectRootPath: string
32+
projectRootPath: string | null = null
3333
): string | null => {
3434
const binaryFromCompilerPackage = path.join(
35-
projectRootPath,
35+
projectRootPath ?? "",
3636
"node_modules",
3737
"rescript",
3838
platformDir,
3939
binaryName
4040
);
4141

42-
if (fs.existsSync(binaryFromCompilerPackage)) {
42+
if (projectRootPath != null && fs.existsSync(binaryFromCompilerPackage)) {
4343
return binaryFromCompilerPackage;
4444
} else if (fs.existsSync(getLegacyBinaryDevPath(binaryName))) {
4545
return getLegacyBinaryDevPath(binaryName);

0 commit comments

Comments
 (0)