@@ -181,7 +181,7 @@ pub fn create_path_for_path(path: &Path) {
181181 fs:: DirBuilder :: new ( ) . recursive ( true ) . create ( path) . unwrap ( ) ;
182182}
183183
184- pub fn get_bsc ( root_path : & Path , workspace_root : & Option < PathBuf > ) -> PathBuf {
184+ fn get_bin_dir ( ) -> PathBuf {
185185 let subfolder = match ( std:: env:: consts:: OS , std:: env:: consts:: ARCH ) {
186186 ( "macos" , "aarch64" ) => "darwin-arm64" ,
187187 ( "macos" , _) => "darwin-x64" ,
@@ -192,21 +192,24 @@ pub fn get_bsc(root_path: &Path, workspace_root: &Option<PathBuf>) -> PathBuf {
192192 _ => panic ! ( "Unsupported architecture" ) ,
193193 } ;
194194
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+
195204 match (
196205 root_path
197- . join ( "node_modules" )
198- . join ( "@rescript" )
199- . join ( subfolder)
200- . join ( "bin" )
206+ . join ( & bin_dir)
201207 . join ( "bsc.exe" )
202208 . canonicalize ( )
203209 . map ( StrippedVerbatimPath :: to_stripped_verbatim_path) ,
204210 workspace_root. as_ref ( ) . map ( |workspace_root| {
205211 workspace_root
206- . join ( "node_modules" )
207- . join ( "@rescript" )
208- . join ( subfolder)
209- . join ( "bin" )
212+ . join ( & bin_dir)
210213 . join ( "bsc.exe" )
211214 . canonicalize ( )
212215 . map ( StrippedVerbatimPath :: to_stripped_verbatim_path)
@@ -219,37 +222,25 @@ pub fn get_bsc(root_path: &Path, workspace_root: &Option<PathBuf>) -> PathBuf {
219222}
220223
221224pub 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 ( ) ;
237226
238227 match (
239228 root_path
240- . join ( & legacy_path_fragment)
229+ . join ( & bin_dir)
230+ . join ( "rescript.exe" )
241231 . canonicalize ( )
242232 . map ( StrippedVerbatimPath :: to_stripped_verbatim_path) ,
243233 workspace_root. map ( |workspace_root| {
244234 workspace_root
245- . join ( & legacy_path_fragment)
235+ . join ( & bin_dir)
236+ . join ( "rescript.exe" )
246237 . canonicalize ( )
247238 . map ( StrippedVerbatimPath :: to_stripped_verbatim_path)
248239 } ) ,
249240 ) {
250241 ( Ok ( path) , _) => path,
251242 ( _, Some ( Ok ( path) ) ) => path,
252- _ => panic ! ( "Could not find rescript-legacy " ) ,
243+ _ => panic ! ( "Could not find rescript.exe " ) ,
253244 }
254245}
255246
0 commit comments