@@ -38,51 +38,33 @@ export let findProjectRootOfFile = (
38
38
}
39
39
} ;
40
40
41
- export let findBscBinaryFromProjectRoot = (
42
- source : p . DocumentUri
43
- ) : null | p . DocumentUri => {
44
- let dir = path . dirname ( source ) ;
45
- // The rescript package's rescript command is a JS wrapper. `rescript format`
46
- // also invokes another JS wrapper. _That_ JS wrapper ultimately calls the
47
- // (unexposed) bsc -format anyway.
48
- let bscNativeReScriptPath = path . join ( dir , c . bscNativeReScriptPartialPath ) ;
49
-
50
- if ( fs . existsSync ( bscNativeReScriptPath ) ) {
51
- return bscNativeReScriptPath ;
52
- } else if ( dir === source ) {
53
- // reached the top
41
+ export let findBinary = (
42
+ binaryDirPath : p . DocumentUri | null ,
43
+ binaryName : string
44
+ ) : p . DocumentUri | null => {
45
+ if ( binaryDirPath == null ) {
54
46
return null ;
47
+ }
48
+ let binaryPath : p . DocumentUri = path . join ( binaryDirPath , binaryName ) ;
49
+ if ( fs . existsSync ( binaryPath ) ) {
50
+ return binaryPath ;
55
51
} else {
56
- return findBscBinaryFromProjectRoot ( dir ) ;
52
+ return null ;
57
53
}
58
54
} ;
59
55
60
- export let findBscBinaryFromConfig = (
61
- pathToBinaryDirFromConfig : p . DocumentUri
62
- ) : null | p . DocumentUri => {
63
- let bscPath = path . join ( pathToBinaryDirFromConfig , c . bscBinName ) ;
64
- if ( fs . existsSync ( bscPath ) ) {
65
- return bscPath ;
66
- }
67
- return null ;
56
+ export let findRescriptBinary = (
57
+ binaryDirPath : p . DocumentUri | string
58
+ ) : p . DocumentUri | null => {
59
+ return findBinary ( binaryDirPath , c . rescriptBinName ) ;
68
60
} ;
69
61
70
- let findBuildBinaryBase = ( rescriptPath : string ) : string | null => {
71
- if ( fs . existsSync ( rescriptPath ) ) {
72
- return rescriptPath ;
73
- }
74
- return null ;
62
+ export let findBscBinary = (
63
+ binaryDirPath : p . DocumentUri | string
64
+ ) : p . DocumentUri | null => {
65
+ return findBinary ( binaryDirPath , c . bscBinName ) ;
75
66
} ;
76
67
77
- export let findRescriptBinaryFromConfig = (
78
- pathToBinaryDirFromConfig : p . DocumentUri
79
- ) =>
80
- findBuildBinaryBase ( path . join ( pathToBinaryDirFromConfig , c . rescriptBinName ) ) ;
81
-
82
- export let findRescriptBinaryFromProjectRoot = (
83
- projectRootPath : p . DocumentUri
84
- ) => findBuildBinaryBase ( path . join ( projectRootPath , c . rescriptNodePartialPath ) ) ;
85
-
86
68
type execResult =
87
69
| {
88
70
kind : "success" ;
0 commit comments