@@ -90,34 +90,28 @@ let findRescriptBinary = (projectRootPath: p.DocumentUri | null) =>
90
90
? utils . findFilePathFromProjectRoot ( projectRootPath , path . join ( c . nodeModulesBinDir , c . rescriptBinName ) )
91
91
: utils . findBinary ( extensionConfiguration . binaryPath , c . rescriptBinName ) ;
92
92
93
- let findBscBinary = ( projectRootPath : p . DocumentUri ) => {
94
- let rescriptBinaryPath = findRescriptBinary ( projectRootPath ) ;
95
- if ( rescriptBinaryPath !== null ) {
96
- let rescriptDirPath = path . join (
97
- path . dirname ( rescriptBinaryPath ) ,
98
- ".." ,
99
- "rescript"
100
- ) ;
101
-
102
- let bscBinaryPath = path . join ( rescriptDirPath , c . platformDir , c . bscExeName ) ;
93
+ let findPlatformPath = ( projectRootPath : p . DocumentUri | null ) => {
94
+ if ( extensionConfiguration . platformPath != null ) {
95
+ return extensionConfiguration . platformPath ;
96
+ }
103
97
104
- // Workaround for darwinarm64 which has no folder yet in ReScript <= 9.1.4
105
- if (
106
- process . platform == "darwin" &&
107
- process . arch == "arm64" &&
108
- ! fs . existsSync ( bscBinaryPath )
109
- ) {
110
- bscBinaryPath = path . join (
111
- rescriptDirPath ,
112
- process . platform ,
113
- c . bscExeName
114
- ) ;
115
- }
98
+ let rescriptDir = utils . findFilePathFromProjectRoot ( projectRootPath , path . join ( "node_modules" , "rescript" ) ) ;
99
+ let platformPath = path . join ( rescriptDir , c . platformDir )
116
100
117
- return bscBinaryPath ;
101
+ // Workaround for darwinarm64 which has no folder yet in ReScript <= 9.1.4
102
+ if (
103
+ process . platform == "darwin" &&
104
+ process . arch == "arm64" &&
105
+ ! fs . existsSync ( platformPath )
106
+ ) {
107
+ platformPath = path . join ( rescriptDir , process . platform ) ;
118
108
}
119
- return null ;
120
- } ;
109
+
110
+ return platformPath ;
111
+ }
112
+
113
+ let findBscExeBinary = ( projectRootPath : p . DocumentUri | null ) =>
114
+ utils . findBinary ( findPlatformPath ( projectRootPath ) , c . bscExeName )
121
115
122
116
interface CreateInterfaceRequestParams {
123
117
uri : string ;
@@ -718,12 +712,12 @@ function format(msg: p.RequestMessage): Array<p.Message> {
718
712
} else {
719
713
// code will always be defined here, even though technically it can be undefined
720
714
let code = getOpenedFileContent ( params . textDocument . uri ) ;
715
+
721
716
let projectRootPath = utils . findProjectRootOfFile ( filePath ) ;
722
- let bscBinaryPath =
723
- projectRootPath === null ? null : findBscBinary ( projectRootPath ) ;
717
+ let bscExeBinaryPath = findBscExeBinary ( projectRootPath ) ;
724
718
725
719
let formattedResult = utils . formatCode (
726
- bscBinaryPath ,
720
+ bscExeBinaryPath ,
727
721
filePath ,
728
722
code ,
729
723
extensionConfiguration . allowBuiltInFormatter
0 commit comments