diff --git a/.luacheckrc b/.luacheckrc index 346359c..1b2b2fd 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -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" diff --git a/luacov-scm-1.rockspec b/luacov-scm-1.rockspec index 4df09b3..6fa01d6 100644 --- a/luacov-scm-1.rockspec +++ b/luacov-scm-1.rockspec @@ -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", @@ -36,6 +38,9 @@ build = { install = { bin = { luacov = "src/bin/luacov" - } - } + }, + }, + copy_directories = { + "src/luacov/reporter/html/static", + }, } diff --git a/src/luacov/reporter/html.lua b/src/luacov/reporter/html.lua index e0fb080..26b49a3 100644 --- a/src/luacov/reporter/html.lua +++ b/src/luacov/reporter/html.lua @@ -1,3 +1,4 @@ +local datafile = require("datafile") local luacov_reporter = require("luacov.reporter") local reporter = {} @@ -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. @@ -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 .. ": ")) diff --git a/src/luacov/reporter/html/lang-lua.js b/src/luacov/reporter/html/static/lang-lua.js similarity index 100% rename from src/luacov/reporter/html/lang-lua.js rename to src/luacov/reporter/html/static/lang-lua.js diff --git a/src/luacov/reporter/html/prettify.js b/src/luacov/reporter/html/static/prettify.js similarity index 100% rename from src/luacov/reporter/html/prettify.js rename to src/luacov/reporter/html/static/prettify.js diff --git a/src/luacov/reporter/html/report.css b/src/luacov/reporter/html/static/report.css similarity index 100% rename from src/luacov/reporter/html/report.css rename to src/luacov/reporter/html/static/report.css diff --git a/src/luacov/reporter/html/report.js b/src/luacov/reporter/html/static/report.js similarity index 100% rename from src/luacov/reporter/html/report.js rename to src/luacov/reporter/html/static/report.js