Skip to content

Commit

Permalink
fix(html): add html reporter to rockspec (#103)
Browse files Browse the repository at this point in the history
  • Loading branch information
Aire-One committed Sep 7, 2023
1 parent f3b3281 commit d2c3f82
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .luacheckrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ std = "min"
include_files = {"src", "spec"}
exclude_files = {
"spec/*/*",
"src/luacov/reporter/html/*.js",
"src/luacov/reporter/html/*.css",
"src/luacov/reporter/html/static/*.js",
"src/luacov/reporter/html/static/*.css",
}
files.spec.std = "+busted"
9 changes: 7 additions & 2 deletions luacov-scm-1.rockspec
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ build = {
["luacov.linescanner"] = "src/luacov/linescanner.lua",
["luacov.reporter"] = "src/luacov/reporter.lua",
["luacov.reporter.default"] = "src/luacov/reporter/default.lua",
["luacov.reporter.html"] = "src/luacov/reporter/html.lua",
["luacov.reporter.html.template"] = "src/luacov/reporter/html/template.lua",
["luacov.runner"] = "src/luacov/runner.lua",
["luacov.stats"] = "src/luacov/stats.lua",
["luacov.tick"] = "src/luacov/tick.lua",
Expand All @@ -36,6 +38,9 @@ build = {
install = {
bin = {
luacov = "src/bin/luacov"
}
}
},
},
copy_directories = {
"src/luacov/reporter/html/static",
},
}
8 changes: 2 additions & 6 deletions src/luacov/reporter/html.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
local datafile = require("datafile")
local luacov_reporter = require("luacov.reporter")

local reporter = {}
Expand All @@ -14,11 +15,6 @@ end
----------------------------------------------------------------
--- parse template
do
local dir = string.gsub(debug.getinfo(1).source, "^@(.+/)[^/]+$", "%1")
local dir_sep = package.config:sub(1, 1)
if not dir_sep:find("[/\\]") then
dir_sep = "/"
end
local template = require("luacov.reporter.html.template")

--- Removes a prefix from a string if it's present.
Expand All @@ -36,7 +32,7 @@ do

-- Returns contents of a file or nil + error message.
local function read_asset(name)
local f, open_err = io.open(dir .. "html" .. dir_sep .. name, "rb")
local f, open_err = datafile.open("src/luacov/reporter/html/static/" .. name, "rb")

if not f then
error(unprefix(open_err, name .. ": "))
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit d2c3f82

Please sign in to comment.