Skip to content

Commit 00ad54c

Browse files
fhammerschmidtzth
authored andcommitted
Fix formatter not being available for macOS ARM with ReScript <= 9.1.4
1 parent 9d7573c commit 00ad54c

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

server/src/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as path from "path";
22

3-
let platformDir =
3+
export let platformDir =
44
process.arch == "arm64" ? process.platform + process.arch : process.platform;
55

66
// See https://microsoft.github.io/language-server-protocol/specification Abstract Message

server/src/server.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,28 @@ let findRescriptBinary = (projectRootPath: p.DocumentUri) =>
108108
let findBscBinary = (projectRootPath: p.DocumentUri) => {
109109
let rescriptBinaryPath = findRescriptBinary(projectRootPath);
110110
if (rescriptBinaryPath !== null) {
111-
return path.join(
111+
let rescriptDirPath = path.join(
112112
path.dirname(rescriptBinaryPath),
113113
"..",
114-
c.platformPath,
115-
c.bscExeName
114+
"rescript"
116115
);
116+
117+
let bscBinaryPath = path.join(rescriptDirPath, c.platformDir, c.bscExeName);
118+
119+
// Workaround for darwinarm64 which has no folder yet in ReScript <= 9.1.4
120+
if (
121+
process.platform == "darwin" &&
122+
process.arch == "arm64" &&
123+
!fs.existsSync(bscBinaryPath)
124+
) {
125+
bscBinaryPath = path.join(
126+
rescriptDirPath,
127+
process.platform,
128+
c.bscExeName
129+
);
130+
}
131+
132+
return bscBinaryPath;
117133
}
118134
return null;
119135
};

0 commit comments

Comments
 (0)