aboutsummaryrefslogtreecommitdiff
path: root/src/lib/builder.lua
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/builder.lua')
-rw-r--r--src/lib/builder.lua16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/lib/builder.lua b/src/lib/builder.lua
index adb55c8..1a9b0af 100644
--- a/src/lib/builder.lua
+++ b/src/lib/builder.lua
@@ -12,6 +12,10 @@ function Builder:from_template(path)
source = path,
}
+ if not builder.template or getmetatable(builder.template) ~= Template then
+ error('invalid template')
+ end
+
builder.source_directory = builder.source:parent()
setmetatable(builder, self)
@@ -41,13 +45,13 @@ function Builder:entries()
for _, value in ipairs(self.template.files) do
entries[#entries + 1] = {
- path = Path:new(value.path),
+ path = self.source_directory / value.path,
env = value.env,
}
end
for _, value in ipairs(self.template.directories) do
- for entry in Path:new(value.path):children() do
+ for entry in (self.source_directory / value.path):children() do
entries[#entries + 1] = {
path = entry,
env = value.env,
@@ -68,8 +72,8 @@ function Builder:build(args)
for entry in self:entries() do
instance:register(
- entry.path,
- entry.path.is_directory and nil or self:process_file(entry)
+ entry.path:relative_to_parent(self.source_directory),
+ not entry.path:is_directory() and self:process_file(entry) or nil
)
end
@@ -77,11 +81,11 @@ function Builder:build(args)
end
function Builder:process_file(file)
- if not (self.source_directory / file.path):exists() then
+ if not file.path:exists() then
error(tostring(file.path) .. ' does not exist.')
end
- local f = (self.source_directory / file.path):open("r")
+ local f = file.path:open("r")
local raw = f:read("*all")
f:close()