@@ -181,7 +181,7 @@ pub fn create_path_for_path(path: &Path) {
181
181
fs:: DirBuilder :: new ( ) . recursive ( true ) . create ( path) . unwrap ( ) ;
182
182
}
183
183
184
- pub fn get_bsc ( root_path : & Path , workspace_root : & Option < PathBuf > ) -> PathBuf {
184
+ fn get_bin_dir ( ) -> PathBuf {
185
185
let subfolder = match ( std:: env:: consts:: OS , std:: env:: consts:: ARCH ) {
186
186
( "macos" , "aarch64" ) => "darwin-arm64" ,
187
187
( "macos" , _) => "darwin-x64" ,
@@ -192,21 +192,24 @@ pub fn get_bsc(root_path: &Path, workspace_root: &Option<PathBuf>) -> PathBuf {
192
192
_ => panic ! ( "Unsupported architecture" ) ,
193
193
} ;
194
194
195
+ Path :: new ( "node_modules" )
196
+ . join ( "@rescript" )
197
+ . join ( subfolder)
198
+ . join ( "bin" )
199
+ }
200
+
201
+ pub fn get_bsc ( root_path : & Path , workspace_root : & Option < PathBuf > ) -> PathBuf {
202
+ let bin_dir = get_bin_dir ( ) ;
203
+
195
204
match (
196
205
root_path
197
- . join ( "node_modules" )
198
- . join ( "@rescript" )
199
- . join ( subfolder)
200
- . join ( "bin" )
206
+ . join ( & bin_dir)
201
207
. join ( "bsc.exe" )
202
208
. canonicalize ( )
203
209
. map ( StrippedVerbatimPath :: to_stripped_verbatim_path) ,
204
210
workspace_root. as_ref ( ) . map ( |workspace_root| {
205
211
workspace_root
206
- . join ( "node_modules" )
207
- . join ( "@rescript" )
208
- . join ( subfolder)
209
- . join ( "bin" )
212
+ . join ( & bin_dir)
210
213
. join ( "bsc.exe" )
211
214
. canonicalize ( )
212
215
. map ( StrippedVerbatimPath :: to_stripped_verbatim_path)
@@ -219,37 +222,25 @@ pub fn get_bsc(root_path: &Path, workspace_root: &Option<PathBuf>) -> PathBuf {
219
222
}
220
223
221
224
pub fn get_rescript_legacy ( root_path : & Path , workspace_root : Option < PathBuf > ) -> PathBuf {
222
- let subfolder = match ( std:: env:: consts:: OS , std:: env:: consts:: ARCH ) {
223
- ( "macos" , "aarch64" ) => "darwin-arm64" ,
224
- ( "macos" , _) => "darwin-x64" ,
225
- ( "linux" , "aarch64" ) => "linux-arm64" ,
226
- ( "linux" , _) => "linux-x64" ,
227
- ( "windows" , "aarch64" ) => "win-arm64" ,
228
- ( "windows" , _) => "win-x64" ,
229
- _ => panic ! ( "Unsupported architecture" ) ,
230
- } ;
231
-
232
- let legacy_path_fragment = Path :: new ( "node_modules" )
233
- . join ( "@rescript" )
234
- . join ( subfolder)
235
- . join ( "bin" )
236
- . join ( "rescript.exe" ) ;
225
+ let bin_dir = get_bin_dir ( ) ;
237
226
238
227
match (
239
228
root_path
240
- . join ( & legacy_path_fragment)
229
+ . join ( & bin_dir)
230
+ . join ( "rescript.exe" )
241
231
. canonicalize ( )
242
232
. map ( StrippedVerbatimPath :: to_stripped_verbatim_path) ,
243
233
workspace_root. map ( |workspace_root| {
244
234
workspace_root
245
- . join ( & legacy_path_fragment)
235
+ . join ( & bin_dir)
236
+ . join ( "rescript.exe" )
246
237
. canonicalize ( )
247
238
. map ( StrippedVerbatimPath :: to_stripped_verbatim_path)
248
239
} ) ,
249
240
) {
250
241
( Ok ( path) , _) => path,
251
242
( _, Some ( Ok ( path) ) ) => path,
252
- _ => panic ! ( "Could not find rescript-legacy " ) ,
243
+ _ => panic ! ( "Could not find rescript.exe " ) ,
253
244
}
254
245
}
255
246
0 commit comments