Skip to content

Commit acd6d7d

Browse files
authored
Use bsc.exe to figure out rescript version (#1083)
* Use `bsc.exe` to figure out rescript version * Add changelog entry.
1 parent 42ec325 commit acd6d7d

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
- 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
2020

21+
- Fix: Absence of Node.js does not hinder LSP server. https://github.com/rescript-lang/rescript-vscode/pull/1083
22+
2123
## 1.62.0
2224

2325
#### :nail_care: Polish

server/src/utils.ts

+9-14
Original file line numberDiff line numberDiff line change
@@ -148,36 +148,31 @@ export let findReScriptVersion = (
148148
return undefined;
149149
}
150150

151-
let rescriptBinary = lookup.findFilePathFromProjectRoot(
152-
projectRoot,
153-
path.join(c.nodeModulesBinDir, c.rescriptBinName)
154-
);
151+
const bscExe = findBinary(findPlatformPath(projectRoot), c.bscExeName);
155152

156-
if (rescriptBinary == null) {
153+
if (bscExe == null) {
157154
return undefined;
158155
}
159156

160157
try {
161-
let version = childProcess.execSync(`${rescriptBinary} -v`);
162-
return version.toString().trim();
158+
let version = childProcess.execSync(`${bscExe} -v`);
159+
return version.toString().replace(/rescript/gi, "").trim();
163160
} catch (e) {
161+
console.error("rescrip binary failed", e);
164162
return undefined;
165163
}
166164
};
167165

168166
export function findReScriptVersionForProjectRoot(projectRootPath:string) : string | undefined {
169-
let rescriptBinary = lookup.findFilePathFromProjectRoot(
170-
projectRootPath,
171-
path.join(c.nodeModulesBinDir, c.rescriptBinName)
172-
);
167+
const bscExe = findBinary(findPlatformPath(projectRootPath), c.bscExeName);
173168

174-
if (rescriptBinary == null) {
169+
if (bscExe == null) {
175170
return undefined;
176171
}
177172

178173
try {
179-
let version = childProcess.execSync(`${rescriptBinary} -v`);
180-
return version.toString().trim();
174+
let version = childProcess.execSync(`${bscExe} -v`);
175+
return version.toString().replace(/rescript/gi, "").trim();
181176
} catch (e) {
182177
return undefined;
183178
}

0 commit comments

Comments
 (0)