diff options
| author | Aotrix <[email protected]> | 2026-09-19 01:28:53 +0200 |
|---|---|---|
| committer | Aotrix <[email protected]> | 2026-09-19 01:28:53 +0200 |
| commit | 82615d77798bf614996600be3684f4f4141446aa (patch) | |
| tree | 609b227e8dbe14b50c43828ddb5a9db98b21671a /lua/aotrix/plugins | |
| parent | 5d5545b7ba7f497c640dcc36816fbd0efbadd276 (diff) | |
wow it seems to work
Diffstat (limited to 'lua/aotrix/plugins')
| -rw-r--r-- | lua/aotrix/plugins/build.lua | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lua/aotrix/plugins/build.lua b/lua/aotrix/plugins/build.lua index 80b4398..f178e4e 100644 --- a/lua/aotrix/plugins/build.lua +++ b/lua/aotrix/plugins/build.lua @@ -71,6 +71,7 @@ return { local addCommandToJsonFile = function(commandBlock, commandsFilePath, directory) local current_json = readJsonFromFile(commandsFilePath) + local is_new_file = false if current_json ~= nil then if current_json[directory] == nil then current_json[directory] = {} @@ -80,12 +81,19 @@ return { command = tostring(commandBlock.command()), description = tostring(commandBlock.description()) }) + else + is_new_file = true end local file, error = io.open(commandsFilePath, 'w') + if is_new_file and file ~= nil then file:write("{}") end if file then local indent = vim.bo.expandtab and (' '):rep(vim.o.shiftwidth) or '\t' - file:write(vim.json.encode(current_json, {indent = indent})) + if current_json ~= nil then + json_content = vim.json.encode(current_json, + {indent = indent}) + file:write(json_content) + end file:close() else print("Error in writeTableToJsonFile: " .. error) |
