diff --git a/CHANGELOG.md b/CHANGELOG.md index 02a4e43b2..00097105b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,8 @@ - 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 +- Fix: Absence of Node.js does not hinder LSP server. https://github.com/rescript-lang/rescript-vscode/pull/1083 + ## 1.62.0 #### :nail_care: Polish diff --git a/server/src/utils.ts b/server/src/utils.ts index a6dd745ef..63d52bebe 100644 --- a/server/src/utils.ts +++ b/server/src/utils.ts @@ -148,36 +148,31 @@ export let findReScriptVersion = ( return undefined; } - let rescriptBinary = lookup.findFilePathFromProjectRoot( - projectRoot, - path.join(c.nodeModulesBinDir, c.rescriptBinName) - ); + const bscExe = findBinary(findPlatformPath(projectRoot), c.bscExeName); - if (rescriptBinary == null) { + if (bscExe == null) { return undefined; } try { - let version = childProcess.execSync(`${rescriptBinary} -v`); - return version.toString().trim(); + let version = childProcess.execSync(`${bscExe} -v`); + return version.toString().replace(/rescript/gi, "").trim(); } catch (e) { + console.error("rescrip binary failed", e); return undefined; } }; export function findReScriptVersionForProjectRoot(projectRootPath:string) : string | undefined { - let rescriptBinary = lookup.findFilePathFromProjectRoot( - projectRootPath, - path.join(c.nodeModulesBinDir, c.rescriptBinName) - ); + const bscExe = findBinary(findPlatformPath(projectRootPath), c.bscExeName); - if (rescriptBinary == null) { + if (bscExe == null) { return undefined; } try { - let version = childProcess.execSync(`${rescriptBinary} -v`); - return version.toString().trim(); + let version = childProcess.execSync(`${bscExe} -v`); + return version.toString().replace(/rescript/gi, "").trim(); } catch (e) { return undefined; }