From 605c4297700faa9c03bf29b55bee464c7706cbc8 Mon Sep 17 00:00:00 2001 From: Lucas Garron Date: Wed, 19 Oct 2022 16:19:50 -0700 Subject: Cache dir loader: Prefer `$BUN_INSTALL` and `$XDG_CACHE_HOME` to `$HOME`. (#1351) This partially addresses https://github.com/oven-sh/bun/issues/696 , by using `$XDG_CACHE_HOME` for those of us who already have that env var set. --- src/install/install.zig | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/install/install.zig b/src/install/install.zig index 60d8e2fdf..7ea14acf6 100644 --- a/src/install/install.zig +++ b/src/install/install.zig @@ -2482,11 +2482,6 @@ pub const PackageManager = struct { return CacheDir{ .path = dir, .is_node_modules = false }; } - if (env_loader.map.get("HOME")) |dir| { - var parts = [_]string{ dir, ".bun/", "install/", "cache/" }; - return CacheDir{ .path = Fs.FileSystem.instance.abs(&parts), .is_node_modules = false }; - } - if (env_loader.map.get("BUN_INSTALL")) |dir| { var parts = [_]string{ dir, "install/", "cache/" }; return CacheDir{ .path = Fs.FileSystem.instance.abs(&parts), .is_node_modules = false }; @@ -2497,6 +2492,11 @@ pub const PackageManager = struct { return CacheDir{ .path = Fs.FileSystem.instance.abs(&parts), .is_node_modules = false }; } + if (env_loader.map.get("HOME")) |dir| { + var parts = [_]string{ dir, ".bun/", "install/", "cache/" }; + return CacheDir{ .path = Fs.FileSystem.instance.abs(&parts), .is_node_modules = false }; + } + var fallback_parts = [_]string{"node_modules/.bun-cache"}; return CacheDir{ .is_node_modules = true, .path = Fs.FileSystem.instance.abs(&fallback_parts) }; } -- cgit v1.2.3