Skip to content

Commit d4cc19d

Browse files
committed
Use semver package for version checks
1 parent da67038 commit d4cc19d

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

server/src/incrementalCompilation.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import readline from "readline";
66
import { performance } from "perf_hooks";
77
import * as p from "vscode-languageserver-protocol";
88
import * as cp from "node:child_process";
9+
import semver from "semver";
910
import config, { send } from "./config";
1011
import * as c from "./constants";
1112
import * as chokidar from "chokidar";
@@ -573,8 +574,11 @@ async function figureOutBscArgs(entry: IncrementallyCompiledFileInfo) {
573574
});
574575

575576
callArgs.push("-color", "never");
576-
if (parseInt(project.rescriptVersion.split(".")[0] ?? "10") >= 11) {
577-
// Only available in v11+
577+
// Only available in v11+
578+
if (
579+
semver.valid(project.rescriptVersion) &&
580+
semver.satisfies(project.rescriptVersion as string, ">=11", { includePrerelease: true })
581+
) {
578582
callArgs.push("-ignore-parse-errors");
579583
}
580584

server/src/utils.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -243,15 +243,8 @@ export let runAnalysisAfterSanityCheck = async (
243243
* with the extension itself.
244244
*/
245245
let shouldUseBuiltinAnalysis =
246-
rescriptVersion?.startsWith("9.") ||
247-
rescriptVersion?.startsWith("10.") ||
248-
rescriptVersion?.startsWith("11.") ||
249-
[
250-
"12.0.0-alpha.1",
251-
"12.0.0-alpha.2",
252-
"12.0.0-alpha.3",
253-
"12.0.0-alpha.4",
254-
].includes(rescriptVersion ?? "");
246+
semver.valid(rescriptVersion) &&
247+
semver.lt(rescriptVersion as string, "12.0.0-alpha.5");
255248

256249
if (!shouldUseBuiltinAnalysis && project != null) {
257250
binaryPath = project.editorAnalysisLocation;

0 commit comments

Comments
 (0)