@@ -38,6 +38,31 @@ export let findProjectRootOfFile = (
38
38
}
39
39
} ;
40
40
41
+ // Check if filePartialPath exists at directory and return the joined path,
42
+ // otherwise recursively check parent directories for it.
43
+ export let findFilePathFromProjectRoot = (
44
+ directory : p . DocumentUri | null , // This must be a directory and not a file!
45
+ filePartialPath : string
46
+ ) : null | p . DocumentUri => {
47
+ if ( directory == null ) {
48
+ return null ;
49
+ }
50
+
51
+ let filePath : p . documentUri = path . join ( directory , filePartialPath ) ;
52
+ if ( fs . existsSync ( filePath ) ) {
53
+ return filePath ;
54
+ }
55
+
56
+ let parentDir : p . documentUri = path . dirname ( directory ) ;
57
+ if ( parentDir === directory ) {
58
+ // reached the top
59
+ return null ;
60
+ }
61
+
62
+ return findFilePathFromProjectRoot ( parentDir , filePartialPath ) ;
63
+ } ;
64
+
65
+ // Check if binaryName exists inside binaryDirPath and return the joined path.
41
66
export let findBinary = (
42
67
binaryDirPath : p . DocumentUri | null ,
43
68
binaryName : string
@@ -53,12 +78,6 @@ export let findBinary = (
53
78
}
54
79
} ;
55
80
56
- export let findRescriptBinary = (
57
- binaryDirPath : p . DocumentUri | null
58
- ) : p . DocumentUri | null => {
59
- return findBinary ( binaryDirPath , c . rescriptBinName ) ;
60
- } ;
61
-
62
81
export let findBscBinary = (
63
82
binaryDirPath : p . DocumentUri | null
64
83
) : p . DocumentUri | null => {
0 commit comments