@@ -146,9 +146,9 @@ let getCompilerVersion = executable => {
146
146
let (output , success ) = Commands . execSync(cmd);
147
147
success ? switch output {
148
148
| [ line ] when Str . string_match(Str . regexp_string("BuckleScript " ), line, 0 ) =>
149
- switch (Str . split(Str . regexp_string ("(Using OCaml" ), String . trim(line))) {
149
+ switch (Str . split(Str . regexp ("( * Using OCaml:? " ), String . trim(line))) {
150
150
| [ _ , version ] => parseOCamlVersion(version)
151
- | _ => Error ("Cannot detect OCaml version from BuckleScript version string: " ++ line)
151
+ | xs => Error ("Cannot detect OCaml version from BuckleScript version string: " ++ line ++ "[" ++ String . concat( " ;" , xs) ++ "]" )
152
152
}
153
153
| [ line ] => parseOCamlVersion(line)
154
154
| _ => Error ("Unable to determine compiler version (ran " ++ cmd ++ "). Output: " ++ String . concat("\n " , output))
@@ -350,19 +350,28 @@ let getCompiler = (rootPath, buildSystem) => {
350
350
};
351
351
352
352
let getRefmt = (rootPath, buildSystem) => {
353
+ let bsRefmt = (bsPlatformDir) =>
354
+ switch (Files . ifExists(bsPlatformDir/+ "lib" /+ "refmt.exe" )){
355
+ | Some (x ) => x
356
+ | None =>
357
+ switch (Files . ifExists(bsPlatformDir /+ nodePlatform /+ "refmt.exe" )){
358
+ | Some (x ) => x
359
+ | None => bsPlatformDir /+ "lib" /+ "refmt3.exe"
360
+ }
361
+ }
353
362
switch (buildSystem) {
354
363
| BsbNative ("3.2.0" , _ ) =>
355
364
let %try_wrap bsPlatformDir = getBsPlatformDir(rootPath);
356
- bsPlatformDir /+ "lib" /+ "refmt.exe"
365
+ bsRefmt ( bsPlatformDir )
357
366
| Bsb (version ) when version > "2.2.0" =>
358
367
let %try_wrap bsPlatformDir = getBsPlatformDir(rootPath);
359
- bsPlatformDir /+ "lib" /+ "refmt.exe"
368
+ bsRefmt ( bsPlatformDir )
360
369
| BsbNative (version , _ ) when version >= "4.0.6" =>
361
370
let %try_wrap bsPlatformDir = getBsPlatformDir(rootPath);
362
- bsPlatformDir /+ "lib" /+ "refmt.exe"
371
+ bsRefmt ( bsPlatformDir )
363
372
| Bsb (_ ) | BsbNative (_ , _ ) =>
364
373
let %try_wrap bsPlatformDir = getBsPlatformDir(rootPath);
365
- bsPlatformDir /+ "lib" /+ "refmt3.exe"
374
+ bsRefmt ( bsPlatformDir )
366
375
| Dune (Esy (_ )) => getExecutableInEsyPath("refmt" , ~pwd= rootPath)
367
376
| Dune (Opam (switchPrefix)) =>
368
377
Ok (switchPrefix /+ "bin" /+ "refmt" )
0 commit comments