Skip to content

Commit

Permalink
refactor: clean up process_image function
Browse files Browse the repository at this point in the history
  • Loading branch information
HakonHarnes committed Mar 24, 2024
1 parent 13e60fc commit 518321c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lua/img-clip/fs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -169,17 +169,20 @@ M.process_image = function(file_path, opts)

if util.has("win32") then
util.warn("Windows does not support image processing yet.")
return nil, 1
return "", 0
end

-- create temp file
local tmp_file_path = file_path .. ".tmp"
M.copy_file(file_path, tmp_file_path)

-- process image
local output, exit_code =
util.execute(string.format("cat '%s' | %s > '%s'", file_path, process_cmd, tmp_file_path), true)
if exit_code == 0 then
M.copy_file(tmp_file_path, file_path)
end

-- remove temp file
util.execute(string.format("rm '%s'", tmp_file_path), true)

return output, exit_code
Expand Down

0 comments on commit 518321c

Please sign in to comment.