Skip to content

Use bsc.exe to figure out rescript version #1083

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

- Fix: bug where incremental compilation crashes when rewatch is being run in a specific package vs the root of the monorepo. https://github.com/rescript-lang/rescript-vscode/pull/1082

- Fix: Absence of Node.js does not hinder LSP server. https://github.com/rescript-lang/rescript-vscode/pull/1083

## 1.62.0

#### :nail_care: Polish
Expand Down
23 changes: 9 additions & 14 deletions server/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,36 +148,31 @@ export let findReScriptVersion = (
return undefined;
}

let rescriptBinary = lookup.findFilePathFromProjectRoot(
projectRoot,
path.join(c.nodeModulesBinDir, c.rescriptBinName)
);
const bscExe = findBinary(findPlatformPath(projectRoot), c.bscExeName);

if (rescriptBinary == null) {
if (bscExe == null) {
return undefined;
}

try {
let version = childProcess.execSync(`${rescriptBinary} -v`);
return version.toString().trim();
let version = childProcess.execSync(`${bscExe} -v`);
return version.toString().replace(/rescript/gi, "").trim();
} catch (e) {
console.error("rescrip binary failed", e);
return undefined;
}
};

export function findReScriptVersionForProjectRoot(projectRootPath:string) : string | undefined {
let rescriptBinary = lookup.findFilePathFromProjectRoot(
projectRootPath,
path.join(c.nodeModulesBinDir, c.rescriptBinName)
);
const bscExe = findBinary(findPlatformPath(projectRootPath), c.bscExeName);

if (rescriptBinary == null) {
if (bscExe == null) {
return undefined;
}

try {
let version = childProcess.execSync(`${rescriptBinary} -v`);
return version.toString().trim();
let version = childProcess.execSync(`${bscExe} -v`);
return version.toString().replace(/rescript/gi, "").trim();
} catch (e) {
return undefined;
}
Expand Down