aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Lucas Garron <code@garron.net> 2022-10-19 16:19:50 -0700
committerGravatar GitHub <noreply@github.com> 2022-10-19 16:19:50 -0700
commit605c4297700faa9c03bf29b55bee464c7706cbc8 (patch)
tree72ff755e3178ea8e77884b4bc01b2631ce735e87
parentb064872d9ae6ec779a588ea9157c6f0e22a99ee1 (diff)
downloadbun-605c4297700faa9c03bf29b55bee464c7706cbc8.tar.gz
bun-605c4297700faa9c03bf29b55bee464c7706cbc8.tar.zst
bun-605c4297700faa9c03bf29b55bee464c7706cbc8.zip
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.
-rw-r--r--src/install/install.zig10
1 files changed, 5 insertions, 5 deletions
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) };
}