only open the file WHEN you need to
This commit is contained in:
@@ -13,9 +13,6 @@ local link = io.read("*line")
|
||||
local title = input_file_name:sub(1, -5) -- assumes .txt extension
|
||||
local output_file_name = title .. ".md"
|
||||
|
||||
local output_file = io.open(output_file_name, "w")
|
||||
assert(output_file, "Could not open \"" .. output_file_name .. "\"")
|
||||
|
||||
local frontmatter = {
|
||||
"---",
|
||||
"title: \"" .. title .. "\"",
|
||||
@@ -29,6 +26,9 @@ if link and #link > 0 then
|
||||
frontmatter[#frontmatter + 1] = "From [" .. link .. "](" .. link .. ")\n"
|
||||
end
|
||||
|
||||
local output_file = io.open(output_file_name, "w")
|
||||
assert(output_file, "Could not open \"" .. output_file_name .. "\"")
|
||||
|
||||
for _, line in ipairs(frontmatter) do
|
||||
output_file:write(line)
|
||||
output_file:write("\n")
|
||||
|
||||
Reference in New Issue
Block a user