@@ -9,30 +9,11 @@ use anyhow::{Context, Result};
99use node_semver:: { Range , Version } ;
1010use serde:: Deserialize ;
1111
12- use crate :: { utils, Config } ;
13-
14- #[ cfg( target_os = "windows" ) ]
15- const PLATFORM : & str = "win" ;
16- #[ cfg( target_os = "macos" ) ]
17- const PLATFORM : & str = "darwin" ;
18- #[ cfg( target_os = "linux" ) ]
19- const PLATFORM : & str = "linux" ;
20-
21- #[ cfg( target_os = "windows" ) ]
22- const EXT : & str = ".zip" ;
23- #[ cfg( target_os = "macos" ) ]
24- const EXT : & str = ".tar.gz" ;
25- #[ cfg( target_os = "linux" ) ]
26- const EXT : & str = ".tar.gz" ;
27-
28- #[ cfg( target_arch = "x86_64" ) ]
29- const ARCH : & str = "x64" ;
30- #[ cfg( target_arch = "x86" ) ]
31- const ARCH : & str = "x86" ;
32- #[ cfg( target_arch = "aarch64" ) ]
33- const ARCH : & str = "arm64" ;
34-
35- const X64 : & str = "x64" ;
12+ use crate :: {
13+ constants,
14+ constants:: { ARCH , EXT , PLATFORM , X64 } ,
15+ Config ,
16+ } ;
3617
3718pub trait NodeVersion {
3819 fn version ( & self ) -> & Version ;
@@ -149,6 +130,7 @@ impl OnlineNodeVersion {
149130 #[ cfg( target_os = "macos" ) ]
150131 fn has_arm ( & self ) -> bool {
151132 for file in self . files . iter ( ) {
133+ // We check for both ARM _and_ OSX since we don't want to fall back to x64 on other platforms.
152134 if file. contains ( "osx" ) && file. contains ( "arm64" ) {
153135 return true ;
154136 }
@@ -218,8 +200,8 @@ impl InstalledNodeVersion {
218200 read_link ( config. get_shims_dir ( ) ) . expect ( "Could not read installation dir" ) ;
219201
220202 let mut required_files = vec ! [ version_dir; 2 ] ;
221- required_files[ 0 ] . set_file_name ( format ! ( "node{}" , utils :: exec_ext ( ) ) ) ;
222- required_files[ 1 ] . set_file_name ( format ! ( "npm{}" , utils :: exec_ext ( ) ) ) ;
203+ required_files[ 0 ] . set_file_name ( format ! ( "node{}" , constants :: EXEC_EXT ) ) ;
204+ required_files[ 1 ] . set_file_name ( format ! ( "npm{}" , constants :: EXEC_EXT ) ) ;
223205
224206 if let Some ( missing_file) = required_files. iter ( ) . find ( |file| !file. exists ( ) ) {
225207 anyhow:: bail!(
0 commit comments