Skip to content

Commit

Permalink
Use --no-cache flag to delete the cache file
Browse files Browse the repository at this point in the history
  • Loading branch information
yanecc committed Jul 1, 2024
1 parent ea6ae4a commit 0223d25
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ After installing [vfox](https://github.com/version-fox/vfox), install the plugin
vfox add clang
```

Next, search and select the version to install. By default, vfox keeps cache for available versions, use `--no-cache` flag to search without cache and rebuild the cache.
Next, search and select the version to install. By default, vfox keeps cache for available versions, use the `--no-cache` flag to delete the cache file.

``` shell
vfox search clang
vfox search clang --no-cache
vfox search clang --no-cache && vfox search clang
```

Install the latest stable version with `latest` tag.
Expand Down
10 changes: 5 additions & 5 deletions hooks/available.lua
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
require("util")

function PLUGIN:Available(ctx)
local option = ctx.args[1]
local noCache = false
if option == "--no-cache" then
noCache = true
local cacheArg = hasValue(ctx.args, "--no-cache")
if cacheArg then
clearCache()
end
return fetchAvailable(noCache)

return fetchAvailable()
end
9 changes: 5 additions & 4 deletions lib/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,10 @@ end

local ClangVersions = fetchVersions()

function fetchAvailable(noCache)
-- available.lua
function fetchAvailable()
local result = {}

if noCache then
clearCache()
end
for i, v in ipairs(ClangVersions) do
if i == 1 then
table.insert(result, {
Expand All @@ -46,8 +44,10 @@ end

function clearCache()
os.remove(RUNTIME.pluginDirPath .. "/available.cache")
os.exit()
end

-- pre_install.lua
function getDownloadInfo(version)
local file

Expand Down Expand Up @@ -101,6 +101,7 @@ function generatePixi(osType, archType)
return file
end

-- post_install.lua
function pixiInstall(path, version)
local condaForge = os.getenv("Conda_Forge") or "conda-forge"
local noStdout = RUNTIME.osType == "windows" and " > nul" or " > /dev/null"
Expand Down

0 comments on commit 0223d25

Please sign in to comment.