diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/exe.zig | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/src/exe.zig b/src/exe.zig index f0d55d4..4d9573e 100644 --- a/src/exe.zig +++ b/src/exe.zig @@ -41,37 +41,37 @@ fn pandocWorker(ctx: *Context, page: []const u8) !void { defer ctx.allocator().free(mtime_str); const f = try fs.FileSwapper.createAt(ctx.allocator(), target_path); + defer f.close(); // open new scope to close the file swapper when we're done writing - { - defer f.close(); - - try f.writer().print( - \\<!-- Generated file, you may edit and discard {s} :) --> - \\ - , - .{page}, - ); - - // make pandoc runs reproducable - var env_map = std.process.EnvMap.init(ctx.allocator()); - defer env_map.deinit(); - try env_map.put("SOURCE_DATE_EPOCH", mtime_str); - - try captureStdout(ctx, &.{ - Context.params.PANDOC, - "--from", - "markdown+wikilinks_title_after_pipe+autolink_bare_uris", - "--to", - "html5", - "--lua-filter", - // TODO: embed the preproc filter - Context.params.PANDOC_PREPROC, - "--strip-comments", - "--output=-", - source_path, - }, &env_map, f.writer().any()); - } + try f.writer().print( + \\<!-- Generated file, you may edit and discard {s} :) --> + \\ + , + .{page}, + ); + + // make pandoc runs reproducable + var env_map = std.process.EnvMap.init(ctx.allocator()); + defer env_map.deinit(); + try env_map.put("SOURCE_DATE_EPOCH", mtime_str); + + try captureStdout(ctx, &.{ + Context.params.PANDOC, + "--from", + "markdown+wikilinks_title_after_pipe+autolink_bare_uris", + "--to", + "html5", + "--lua-filter", + // TODO: embed the preproc filter + Context.params.PANDOC_PREPROC, + "--strip-comments", + "--output=-", + source_path, + }, &env_map, f.writer().any()); + + // swap now, we want to edit mtime + try f.swap(); // fixup mtime of the resulting file, this has to happen after the file // swapper has been closed, because it works on a tmp file which is going |