Skip to content

Commit a037a23

Browse files
committed
Replace findReScriptVersion(filePath) with findReScriptVersionForProjectRoot(projectRootPath)
1 parent d7bc10a commit a037a23

File tree

1 file changed

+3
-22
lines changed

1 file changed

+3
-22
lines changed

server/src/utils.ts

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -237,30 +237,11 @@ export let formatCode = (
237237
}
238238
};
239239

240-
export let findReScriptVersion = async (
241-
filePath: p.DocumentUri
242-
): Promise<string | undefined> => {
243-
let projectRoot = findProjectRootOfFile(filePath);
244-
if (projectRoot == null) {
240+
export async function findReScriptVersionForProjectRoot(projectRootPath: string | null): Promise<string | undefined> {
241+
if (projectRootPath == null) {
245242
return undefined;
246243
}
247244

248-
const bscExe = findBinary(findPlatformPath(projectRoot), c.bscExeName);
249-
250-
if (bscExe == null) {
251-
return undefined;
252-
}
253-
254-
try {
255-
let version = childProcess.execSync(`${bscExe} -v`);
256-
return version.toString().replace(/rescript/gi, "").trim();
257-
} catch (e) {
258-
console.error("rescrip binary failed", e);
259-
return undefined;
260-
}
261-
};
262-
263-
export async function findReScriptVersionForProjectRoot(projectRootPath: string): Promise<string | undefined> {
264245
const bscExe = await findBscExeBinary(projectRootPath)
265246

266247
if (bscExe == null) {
@@ -294,7 +275,7 @@ export let runAnalysisAfterSanityCheck = async (
294275
}
295276
let rescriptVersion =
296277
projectsFiles.get(projectRootPath ?? "")?.rescriptVersion ??
297-
await findReScriptVersion(filePath);
278+
await findReScriptVersionForProjectRoot(projectRootPath)
298279

299280
let binaryPath = builtinBinaryPath;
300281

0 commit comments

Comments
 (0)