-
Notifications
You must be signed in to change notification settings - Fork 60
Description
Extension version: 1.7.6 (latest master)
The Format document
feature uses the bsc.exe
binary:
rescript-vscode/server/src/server.ts
Lines 740 to 742 in 877f874
let projectRootPath = utils.findProjectRootOfFile(filePath); | |
let bscBinaryPath = | |
projectRootPath === null ? null : findBscBinary(projectRootPath); |
The location of the bsc.exe
binary is determined as follows:
rescript-vscode/server/src/server.ts
Lines 112 to 121 in 877f874
let findBscBinary = (projectRootPath: p.DocumentUri) => { | |
let rescriptBinaryPath = findRescriptBinary(projectRootPath); | |
if (rescriptBinaryPath !== null) { | |
let rescriptDirPath = path.join( | |
path.dirname(rescriptBinaryPath), | |
"..", | |
"rescript" | |
); | |
let bscBinaryPath = path.join(rescriptDirPath, c.platformDir, c.bscExeName); |
It is "reverse engineered" from the location of the rescript
binary:
rescript-vscode/server/src/server.ts
Lines 107 to 110 in 877f874
let findRescriptBinary = (projectRootPath: p.DocumentUri) => | |
extensionConfiguration.binaryPath == null | |
? findBinaryPathFromProjectRoot(projectRootPath) | |
: utils.findRescriptBinary(extensionConfiguration.binaryPath); |
rescript-vscode/server/src/utils.ts
Lines 56 to 60 in 877f874
export let findRescriptBinary = ( | |
binaryDirPath: p.DocumentUri | null | |
): p.DocumentUri | null => { | |
return findBinary(binaryDirPath, c.rescriptBinName); | |
}; |
The node_modules/.bin/rescript
symlink exists both at the monorepo top level node_modules
and the subdir node_modules
, which makes findRescriptBinary
return src/monorepo/subdir/node_modules/.bin/rescript
.
However, the node_modules/rescript
directory usually exists only at the monorepo top level, so when the path of the rescript
binary is used to derive the location of bsc.exe
, this results in the non-existent path src/monorepo/subdir/node_modules/rescript/linux/bsc.exe
. It should actually return src/monorepo/node_modules/rescript/linux/bsc.exe
(without subdir
).
To make things more complicated, if node_modules/rescript
does exist in the subdir, that directory should be used. This may be the case when multiple rescript
versions are used in the same monorepo.