Skip to content

Commit db12558

Browse files
committed
zig init: allow the use of variables in templates like $root and $version
1 parent a495d20 commit db12558

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

src/main.zig

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7483,12 +7483,6 @@ fn loadManifest(
74837483
const Replacement = struct {
74847484
variable: []const u8,
74857485
replacement: []const u8,
7486-
7487-
pub inline fn check_variable(self: *@This()) !void {
7488-
if (self.variable.len < 2) {
7489-
return error.InvalidVariable;
7490-
}
7491-
}
74927486
};
74937487

74947488
const Templates = struct {
@@ -7529,7 +7523,6 @@ const Templates = struct {
75297523
// replace variables like $root and $version with the project name
75307524
// and zig compiler version respectively
75317525
while (iterator.next()) |line| {
7532-
75337526
var i: usize = 0;
75347527
while (i < line.len) : (i += 1) {
75357528
const c = line[i];
@@ -7539,7 +7532,9 @@ const Templates = struct {
75397532
var found: bool = false;
75407533

75417534
for (replace_items) |replacement| {
7542-
try replacement.check_variable();
7535+
if (replacement.variable.len < 2) {
7536+
return error.InvalidVariable;
7537+
}
75437538

75447539
if (line.len - i < replacement.variable.len) {
75457540
continue;

0 commit comments

Comments
 (0)