diff --git a/registry.toml b/registry.toml index 12193e4aee..ebb873b069 100644 --- a/registry.toml +++ b/registry.toml @@ -97,6 +97,7 @@ btrace.backends = ["asdf:joschi/asdf-btrace"] buf.backends = ["ubi:bufbuild/buf", "asdf:truepay/asdf-buf"] buildpack.backends = ["asdf:johnlayton/asdf-buildpack"] bun.backends = ["core:bun", "vfox:ahai-code/vfox-bun"] +bun.test = ["bun --version", "{{version}}"] bundler.backends = ["asdf:jonathanmorley/asdf-bundler"] cabal.backends = ["asdf:sestrella/asdf-ghcup"] caddy.backends = ["aqua:caddyserver/caddy", "asdf:salasrod/asdf-caddy"] diff --git a/src/file.rs b/src/file.rs index 24992edb0b..999af0de5b 100644 --- a/src/file.rs +++ b/src/file.rs @@ -719,7 +719,7 @@ mod tests { fn test_dir_subdirs() { reset(); let subdirs = dir_subdirs(&dirs::HOME).unwrap(); - assert!(subdirs.contains(&"cwd".to_string())); + assert!(subdirs.contains("cwd")); } #[test] diff --git a/src/plugins/core/bun.rs b/src/plugins/core/bun.rs index cf778bb737..509303c041 100644 --- a/src/plugins/core/bun.rs +++ b/src/plugins/core/bun.rs @@ -9,12 +9,11 @@ use crate::backend::Backend; use crate::cli::args::BackendArg; use crate::cli::version::{ARCH, OS}; use crate::cmd::CmdLineRunner; -use crate::github::GithubRelease; -use crate::http::{HTTP, HTTP_FETCH}; +use crate::http::HTTP; use crate::install_context::InstallContext; use crate::toolset::{ToolRequest, ToolVersion}; use crate::ui::progress_report::SingleReport; -use crate::{file, plugins}; +use crate::{file, github, plugins}; #[derive(Debug)] pub struct BunPlugin { @@ -29,7 +28,7 @@ impl BunPlugin { } fn bun_bin(&self, tv: &ToolVersion) -> PathBuf { - tv.install_path().join("bin/bun") + tv.install_path().join("bin").join(bun_bin_name()) } fn test_bun(&self, ctx: &InstallContext) -> Result<()> { @@ -66,11 +65,13 @@ impl BunPlugin { ctx.tv .download_path() .join(format!("bun-{}-{}", os(), arch())) - .join("bun"), + .join(bun_bin_name()), self.bun_bin(&ctx.tv), )?; - file::make_executable(self.bun_bin(&ctx.tv))?; - file::make_symlink(Path::new("./bun"), &ctx.tv.install_path().join("bin/bunx"))?; + if cfg!(unix) { + file::make_executable(self.bun_bin(&ctx.tv))?; + file::make_symlink(Path::new("./bun"), &ctx.tv.install_path().join("bin/bunx"))?; + } Ok(()) } @@ -85,9 +86,7 @@ impl Backend for BunPlugin { } fn _list_remote_versions(&self) -> Result> { - let releases: Vec = - HTTP_FETCH.json("https://api.github.com/repos/oven-sh/bun/releases?per_page=100")?; - let versions = releases + let versions = github::list_releases("oven-sh/bun")? .into_iter() .map(|r| r.tag_name) .filter_map(|v| v.strip_prefix("bun-v").map(|v| v.to_string())) @@ -129,8 +128,20 @@ fn arch() -> &'static str { "x64-baseline" } } else if cfg!(target_arch = "aarch64") { - "aarch64" + if cfg!(windows) { + "x64" + } else { + "aarch64" + } } else { &ARCH } } + +fn bun_bin_name() -> &'static str { + if cfg!(windows) { + "bun.exe" + } else { + "bun" + } +} diff --git a/src/plugins/core/mod.rs b/src/plugins/core/mod.rs index d6c2132aa4..c8a2110c92 100644 --- a/src/plugins/core/mod.rs +++ b/src/plugins/core/mod.rs @@ -10,7 +10,6 @@ use crate::cli::args::BackendArg; use crate::config::SETTINGS; use crate::env; use crate::env::PATH_KEY; -#[cfg(unix)] use crate::plugins::core::bun::BunPlugin; use crate::plugins::core::deno::DenoPlugin; #[cfg(unix)] @@ -24,7 +23,6 @@ use crate::plugins::core::zig::ZigPlugin; use crate::timeout::run_with_timeout; use crate::toolset::ToolVersion; -#[cfg(unix)] mod bun; mod deno; #[cfg(unix)] @@ -53,7 +51,7 @@ pub static CORE_PLUGINS: Lazy = Lazy::new(|| { ]; #[cfg(windows)] let plugins: Vec> = vec![ - // Arc::new(BunPlugin::new()), + Arc::new(BunPlugin::new()), Arc::new(DenoPlugin::new()), // Arc::new(ErlangPlugin::new()), Arc::new(GoPlugin::new()),