diff options
| -rw-r--r-- | lua/aotrix/build.lua | 10 |
1 files changed, 8 insertions, 2 deletions
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 |
