Skip to content

Fix formatter not being available for macOS ARM with ReScript <= 9.1.4 #554

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 1 commit into from
Aug 18, 2022
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: 1 addition & 1 deletion server/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as path from "path";

let platformDir =
export let platformDir =
process.arch == "arm64" ? process.platform + process.arch : process.platform;

// See https://microsoft.github.io/language-server-protocol/specification Abstract Message
Expand Down
22 changes: 19 additions & 3 deletions server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,28 @@ let findRescriptBinary = (projectRootPath: p.DocumentUri) =>
let findBscBinary = (projectRootPath: p.DocumentUri) => {
let rescriptBinaryPath = findRescriptBinary(projectRootPath);
if (rescriptBinaryPath !== null) {
return path.join(
let rescriptDirPath = path.join(
path.dirname(rescriptBinaryPath),
"..",
c.platformPath,
c.bscExeName
"rescript"
);

let bscBinaryPath = path.join(rescriptDirPath, c.platformDir, c.bscExeName);

// Workaround for darwinarm64 which has no folder yet in ReScript <= 9.1.4
if (
process.platform == "darwin" &&
process.arch == "arm64" &&
!fs.existsSync(bscBinaryPath)
) {
bscBinaryPath = path.join(
rescriptDirPath,
process.platform,
c.bscExeName
);
}

return bscBinaryPath;
}
return null;
};
Expand Down