@@ -79,14 +79,16 @@ let codeActionsFromDiagnostics: codeActions.filesCodeActions = {};
79
79
// will be properly defined later depending on the mode (stdio/node-rpc)
80
80
let send : ( msg : p . Message ) => void = ( _ ) => { } ;
81
81
82
- let findBinaryDirPathFromProjectRoot = (
83
- directory : p . DocumentUri // This must be a directory and not a file!
82
+ let findBinaryFromProjectDirRec = (
83
+ directory : p . DocumentUri , // This must be a directory and not a file!
84
+ targetDir : p . DocumentUri ,
85
+ binaryName : p . DocumentUri
84
86
) : null | p . DocumentUri => {
85
- let binaryDirPath = path . join ( directory , c . nodeModulesBinDir ) ;
86
- let binaryPath = path . join ( binaryDirPath , c . rescriptBinName ) ;
87
+ let binaryDirPath = path . join ( directory , targetDir ) ;
88
+ let binaryPath = path . join ( binaryDirPath , binaryName ) ;
87
89
88
90
if ( fs . existsSync ( binaryPath ) ) {
89
- return binaryDirPath ;
91
+ return binaryPath ;
90
92
}
91
93
92
94
let parentDir = path . dirname ( directory ) ;
@@ -95,19 +97,22 @@ let findBinaryDirPathFromProjectRoot = (
95
97
return null ;
96
98
}
97
99
98
- return findBinaryDirPathFromProjectRoot ( parentDir ) ;
100
+ return findBinaryFromProjectDirRec ( parentDir , targetDir , binaryName ) ;
99
101
} ;
100
102
101
- let getBinaryDirPath = ( projectRootPath : p . DocumentUri ) =>
102
- extensionConfiguration . binaryPath == null
103
- ? findBinaryDirPathFromProjectRoot ( projectRootPath )
104
- : extensionConfiguration . binaryPath ;
105
-
106
103
let findRescriptBinary = ( projectRootPath : p . DocumentUri ) =>
107
- utils . findRescriptBinary ( getBinaryDirPath ( projectRootPath ) ) ;
104
+ extensionConfiguration . binaryPath == null
105
+ ? findBinaryFromProjectDirRec (
106
+ projectRootPath ,
107
+ c . nodeModulesBinDir ,
108
+ c . rescriptBinName
109
+ )
110
+ : utils . findRescriptBinary ( extensionConfiguration . binaryPath ) ;
108
111
109
112
let findBscBinary = ( projectRootPath : p . DocumentUri ) =>
110
- utils . findBscBinary ( getBinaryDirPath ( projectRootPath ) ) ;
113
+ extensionConfiguration . binaryPath == null
114
+ ? findBinaryFromProjectDirRec ( projectRootPath , c . platformPath , c . bscExeName )
115
+ : utils . findBscBinary ( extensionConfiguration . binaryPath ) ;
111
116
112
117
interface CreateInterfaceRequestParams {
113
118
uri : string ;
@@ -312,9 +317,10 @@ let openedFile = (fileUri: string, fileContent: string) => {
312
317
method : "window/showMessage" ,
313
318
params : {
314
319
type : p . MessageType . Error ,
315
- message : `Can't find ReScript binary in the directory ${ getBinaryDirPath (
316
- projectRootPath
317
- ) } `,
320
+ message :
321
+ extensionConfiguration . binaryPath == null
322
+ ? "Can't find ReScript binary"
323
+ : `Can't find ReScript binary in the directory ${ extensionConfiguration . binaryPath } ` ,
318
324
} ,
319
325
} ;
320
326
send ( request ) ;
0 commit comments