Skip to content

Commit 5f5fc8e

Browse files
committed
Use bsc.exe to figure out rescript version
1 parent 42ec325 commit 5f5fc8e

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

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)