Skip to content

Commit

Permalink
fix: remove run key before saving the state
Browse files Browse the repository at this point in the history
  • Loading branch information
saccarosium committed Aug 5, 2023
1 parent 81f239f commit 988a8c6
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lua/paq.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ local status = {
local logpath = vim.fn.has("nvim-0.8") == 1 and vim.fn.stdpath("log") or vim.fn.stdpath("cache")
local logfile = logpath .. "/paq.log"
local lockfile = vim.fn.stdpath("data") .. "/paq-lock.json"
local packages = {} -- "name" = {options...} pairs
local packages = {}
local lock = {}

-- This is done only once. Doing it for every process seems overkill
Expand Down Expand Up @@ -95,9 +95,15 @@ local function lock_load()
end

local function state_write()
-- remove run key since can have a function in it, and
-- json.encode doesn't support functions
local pkgs = packages
for p, _ in pairs(pkgs) do
pkgs[p].run = nil
end
local file = uv.fs_open(lockfile, "w", 438)
if file then
local ok, result = pcall(vim.json.encode, packages)
local ok, result = pcall(vim.json.encode, pkgs)
if not ok then
error(result)
end
Expand Down

0 comments on commit 988a8c6

Please sign in to comment.