From 8c7c20149ce4f4670879b2f5cd9707575f3d29f4 Mon Sep 17 00:00:00 2001 From: Aotrix <9aotrix@protonmail.com> Date: Mon, 15 Jun 2026 21:51:12 +0200 Subject: Separate read from write function --- lua/aotrix/build.lua | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'lua/aotrix') diff --git a/lua/aotrix/build.lua b/lua/aotrix/build.lua index af9e0ea..ffdfe7d 100644 --- a/lua/aotrix/build.lua +++ b/lua/aotrix/build.lua @@ -17,13 +17,17 @@ function executeCommandInTerminal(command) end end -function writeJsonToFile(json, filePath) +function readJsonFromFile(filePath) local file, error = io.open(filePath, 'r') if file ~= nil then local content = file:read("*a") local decoded_json = vim.json.decode(content) - print(decoded_json["first_element"]) + return decoded_json end + return nil +end + +function writeJsonToFile(json, filePath) -- local file, error = io.open(filePath, 'w') -- if file then -- file:write(tostring(json)) @@ -37,6 +41,8 @@ function appendCommandsFromDirectory(commands, directory) encoded_json = vim.json.encode({first_element = 1, second_element = 2}) personal_commands_path = string.format("%s/personal_commands.json", data_path) + readJsonFromFile(personal_commands_path) + -- print(readJsonFromFile(personal_commands_path)["first_element"]) writeJsonToFile(encoded_json, personal_commands_path) end -- cgit v1.2.3