diff --git a/nu-git-manager/fs/store.nu b/nu-git-manager/fs/store.nu index 4446edc1..c4f9f28d 100644 --- a/nu-git-manager/fs/store.nu +++ b/nu-git-manager/fs/store.nu @@ -8,9 +8,12 @@ export def get-repo-store-path []: nothing -> path { } export def get-repo-store-cache-path []: nothing -> path { - $env.XDG_CACHE_HOME? - | default ($nu.home-path | path join ".cache") - | path join "nu-git-manager/cache.nuon" + $env.GIT_REPOS_CACHE? + | default ( + $env.XDG_CACHE_HOME? + | default ($nu.home-path | path join ".cache") + | path join "nu-git-manager/cache.nuon" + ) | path expand | path sanitize } diff --git a/nu-git-manager/mod.nu b/nu-git-manager/mod.nu index 81239e61..a6d49c25 100644 --- a/nu-git-manager/mod.nu +++ b/nu-git-manager/mod.nu @@ -22,6 +22,7 @@ def "nu-complete git-protocols" []: nothing -> table record nothing { mkdir ($cache_file | path dirname) print --no-newline "updating cache... " - list-repos-in-store | save --force $cache_file + let foo = list-repos-in-store + print ($foo | describe) + print $foo + $foo | to nuon | save --force $cache_file print "done" null @@ -271,7 +281,12 @@ export def "gm remove" [ check-cache-file $cache_file print --no-newline "updating cache... " - open $cache_file | where $it != ($root | path join $repo_to_remove) | save --force $cache_file + open --raw $cache_file + | from nuon + | where $it != ($root + | path join $repo_to_remove) + | to nuon + | save --force $cache_file print "done" null diff --git a/tests/mod.nu b/tests/mod.nu index 32a87e5f..4ac29cc0 100644 --- a/tests/mod.nu +++ b/tests/mod.nu @@ -93,10 +93,12 @@ export def get-store-root [] { export def get-repo-cache [] { let cases = [ - [env, expected]; + [env, expected]; - [{XDG_CACHE_HOME: null}, "~/.cache/nu-git-manager/cache.nuon"], - [{XDG_CACHE_HOME: "~/xdg"}, "~/xdg/nu-git-manager/cache.nuon"], + [{GIT_REPOS_CACHE: null, XDG_CACHE_HOME: null}, "~/.cache/nu-git-manager/cache.nuon"], + [{GIT_REPOS_CACHE: "~/my_cache", XDG_CACHE_HOME: null}, "~/my_cache"], + [{GIT_REPOS_CACHE: null, XDG_CACHE_HOME: "~/xdg"}, "~/xdg/nu-git-manager/cache.nuon"], + [{GIT_REPOS_CACHE: "~/my_cache", XDG_CACHE_HOME: "~/xdg"}, "~/my_cache"], ] for case in $cases {