Skip to content

Commit

Permalink
fix: disable health message on startup (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
HakonHarnes authored Mar 13, 2024
1 parent b474c8c commit 5a8efb3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
6 changes: 0 additions & 6 deletions lua/img-clip/init.lua
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
local clipboard = require("img-clip.clipboard")
local config = require("img-clip.config")
local paste = require("img-clip.paste")
local util = require("img-clip.util")

local M = {}

---@param opts? table
M.setup = function(opts)
config.setup(opts)

if not clipboard.get_clip_cmd() then
util.error("Could not get clipboard command. See :checkhealth img-clip.")
end
end

---@param opts? table
Expand Down
6 changes: 6 additions & 0 deletions lua/img-clip/paste.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ M.paste_image = function(opts, input)
return false
end

-- ensure clipboard command is valid
if not clipboard.get_clip_cmd() then
util.error("Could not get clipboard command. See :checkhealth img-clip.")
return false
end

-- if no input is provided, check clipboard content
if clipboard.content_is_image() then
return M.paste_image_from_clipboard(opts)
Expand Down
10 changes: 10 additions & 0 deletions tests/paste_spec.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
local clipboard = require("img-clip.clipboard")
local paste = require("img-clip.paste")
local config = require("img-clip.config")
local util = require("img-clip.util")
local spy = require("luassert.spy")

describe("paste", function()
Expand All @@ -9,6 +10,15 @@ describe("paste", function()
config.get_config = function()
return config.opts
end
os.getenv = function(env)
return env == "DISPLAY"
end
util.has = function()
return false
end
util.executable = function(cmd)
return cmd == "xclip"
end
end)

describe("paste_image", function()
Expand Down

0 comments on commit 5a8efb3

Please sign in to comment.