Skip to content

Commit 8c46dea

Browse files
committed
fix: add .gitignore to scaffolded projects and fix defer flush
1 parent 57f89d6 commit 8c46dea

File tree

4 files changed

+6
-2
lines changed

4 files changed

+6
-2
lines changed

AGENTS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ try list.append(allocator, 42);
2727
```zig
2828
var buf: [4096]u8 = undefined;
2929
const writer = std.fs.File.stdout().writer(&buf);
30-
defer writer.flush();
30+
defer writer.flush() catch {};
3131
try writer.print("hello {s}\n", .{"world"});
3232
```
3333

src/main.zig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const template_build_zig = @embedFile("templates/build.zig.template");
1010
const template_main_zig = @embedFile("templates/main.zig.template");
1111
const template_build_zig_zon = @embedFile("templates/build.zig.zon.template");
1212
const template_agents_md = @embedFile("templates/AGENTS.md.template");
13+
const template_gitignore = @embedFile("templates/.gitignore.template");
1314

1415
pub fn main() !void {
1516
var debug_allocator: std.heap.DebugAllocator(.{}) = .init;
@@ -123,6 +124,7 @@ fn initProject(allocator: std.mem.Allocator) !void {
123124
try cwd.writeFile(.{ .sub_path = "build.zig.zon", .data = try substitute(allocator, template_build_zig_zon, name) });
124125
try cwd.writeFile(.{ .sub_path = "src/main.zig", .data = template_main_zig });
125126
try cwd.writeFile(.{ .sub_path = "AGENTS.md", .data = template_agents_md });
127+
try cwd.writeFile(.{ .sub_path = ".gitignore", .data = template_gitignore });
126128

127129
// Run zig build to get suggested fingerprint from error message
128130
const result = std.process.Child.run(.{

src/templates/.gitignore.template

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.zig-cache/
2+
zig-out/

src/templates/AGENTS.md.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ try list.append(allocator, 42);
2727
```zig
2828
var buf: [4096]u8 = undefined;
2929
const writer = std.fs.File.stdout().writer(&buf);
30-
defer writer.flush();
30+
defer writer.flush() catch {};
3131
try writer.print("hello {s}\n", .{"world"});
3232
```
3333

0 commit comments

Comments
 (0)