Skip to content

Commit

Permalink
Arch is Copy
Browse files Browse the repository at this point in the history
  • Loading branch information
mo8it committed Aug 12, 2024
1 parent 3ee7bfd commit 8edbe3d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/arch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,18 @@ impl Arch {

#[cfg(unix)]
/// handle common case: Apple Silicon / Node < 16
pub fn get_safe_arch<'a>(arch: &'a Arch, version: &Version) -> &'a Arch {
pub fn get_safe_arch(arch: Arch, version: &Version) -> Arch {
use crate::system_info::{platform_arch, platform_name};

match (platform_name(), platform_arch(), version) {
("darwin", "arm64", Version::Semver(v)) if v.major < 16 => &Arch::X64,
("darwin", "arm64", Version::Semver(v)) if v.major < 16 => Arch::X64,
_ => arch,
}
}

#[cfg(windows)]
/// handle common case: Apple Silicon / Node < 16
pub fn get_safe_arch<'a>(arch: &'a Arch, _version: &Version) -> &'a Arch {
pub fn get_safe_arch(arch: Arch, _version: &Version) -> Arch {
arch
}

Expand Down
2 changes: 1 addition & 1 deletion src/commands/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ impl Command for Install {
};

// Automatically swap Apple Silicon to x64 arch for appropriate versions.
let safe_arch = get_safe_arch(&config.arch, &version);
let safe_arch = get_safe_arch(config.arch, &version);

let version_str = format!("Node {}", &version);
outln!(
Expand Down
10 changes: 5 additions & 5 deletions src/downloader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub enum Error {
}

#[cfg(unix)]
fn filename_for_version(version: &Version, arch: &Arch) -> String {
fn filename_for_version(version: &Version, arch: Arch) -> String {
format!(
"node-{node_ver}-{platform}-{arch}.tar.xz",
node_ver = &version,
Expand All @@ -56,7 +56,7 @@ fn filename_for_version(version: &Version, arch: &Arch) -> String {
)
}

fn download_url(base_url: &Url, version: &Version, arch: &Arch) -> Url {
fn download_url(base_url: &Url, version: &Version, arch: Arch) -> Url {
Url::parse(&format!(
"{}/{}/{}",
base_url.as_str().trim_end_matches('/'),
Expand All @@ -80,7 +80,7 @@ pub fn install_node_dist<P: AsRef<Path>>(
version: &Version,
node_dist_mirror: &Url,
installations_dir: P,
arch: &Arch,
arch: Arch,
show_progress: bool,
) -> Result<(), Error> {
let installation_dir = PathBuf::from(installations_dir.as_ref()).join(version.v_str());
Expand All @@ -105,7 +105,7 @@ pub fn install_node_dist<P: AsRef<Path>>(
if response.status() == 404 {
return Err(Error::VersionNotFound {
version: version.clone(),
arch: arch.clone(),
arch,
});
}

Expand Down Expand Up @@ -179,7 +179,7 @@ mod tests {
let version = Version::parse("12.0.0").unwrap();
let arch = Arch::X64;
let node_dist_mirror = Url::parse("https://nodejs.org/dist/").unwrap();
install_node_dist(&version, &node_dist_mirror, path, &arch, false)
install_node_dist(&version, &node_dist_mirror, path, arch, false)
.expect("Can't install Node 12");

let mut location_path = path.join(version.v_str()).join("installation");
Expand Down

0 comments on commit 8edbe3d

Please sign in to comment.