File tree 2 files changed +20
-3
lines changed
2 files changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -268,7 +268,7 @@ let openedFile = (fileUri: string, fileContent: string) => {
268
268
filesDiagnostics : { } ,
269
269
namespaceName :
270
270
namespaceName . kind === "success" ? namespaceName . result : null ,
271
- rescriptVersion : utils . findReScriptVersion ( projectRootPath ) ,
271
+ rescriptVersion : utils . findReScriptVersionForProjectRoot ( projectRootPath ) ,
272
272
bsbWatcherByEditor : null ,
273
273
bscBinaryLocation : utils . findBscExeBinary ( projectRootPath ) ,
274
274
editorAnalysisLocation : utils . findEditorAnalysisBinary ( projectRootPath ) ,
Original file line number Diff line number Diff line change @@ -67,8 +67,7 @@ export let findProjectRootOfFile = (
67
67
if ( foundRootFromProjectFiles != null ) {
68
68
return foundRootFromProjectFiles ;
69
69
} else {
70
- const dirStat = fs . statSync ( source ) ;
71
- const isDir = dirStat . isDirectory ( ) ;
70
+ const isDir = path . extname ( source ) === "" ;
72
71
return findProjectRootOfFileInDir (
73
72
isDir && ! allowDir ? path . join ( source , "dummy.res" ) : source
74
73
) ;
@@ -166,6 +165,24 @@ export let findReScriptVersion = (
166
165
}
167
166
} ;
168
167
168
+ export function findReScriptVersionForProjectRoot ( projectRootPath :string ) : string | undefined {
169
+ let rescriptBinary = lookup . findFilePathFromProjectRoot (
170
+ projectRootPath ,
171
+ path . join ( c . nodeModulesBinDir , c . rescriptBinName )
172
+ ) ;
173
+
174
+ if ( rescriptBinary == null ) {
175
+ return undefined ;
176
+ }
177
+
178
+ try {
179
+ let version = childProcess . execSync ( `${ rescriptBinary } -v` ) ;
180
+ return version . toString ( ) . trim ( ) ;
181
+ } catch ( e ) {
182
+ return undefined ;
183
+ }
184
+ }
185
+
169
186
// This is the path for the _builtin_ legacy analysis, that works for versions 11 and below.
170
187
let builtinBinaryPath : string | null = null ;
171
188
if ( fs . existsSync ( c . builtinAnalysisDevPath ) ) {
You can’t perform that action at this time.
0 commit comments