Skip to content

Commit c0e980c

Browse files
authored
Merge branch 'main' into main
2 parents 96590f9 + f35bebc commit c0e980c

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

src/upgrade.zig

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,28 @@ pub fn run(
317317
try stdout.print("Now running zvm {s}\n", .{latest_version});
318318
try stdout.flush();
319319

320+
// Show the active Zig version
321+
if (zvm.getActiveVersion(allocator)) |active| {
322+
defer allocator.free(active);
323+
var ver_buf: [std.fs.max_path_bytes]u8 = undefined;
324+
const ver_path = zvm.versionPath(&ver_buf, active);
325+
const zig_path = std.fmt.allocPrint(allocator, "{s}/zig", .{ver_path}) catch return;
326+
defer allocator.free(zig_path);
327+
328+
const ver_result = std.process.run(allocator, zvm.io, .{
329+
.argv = &.{ zig_path, "version" },
330+
.stdout_limit = .limited(1024),
331+
}) catch return;
332+
defer allocator.free(ver_result.stdout);
333+
defer allocator.free(ver_result.stderr);
334+
335+
if (ver_result.stdout.len > 0) {
336+
const ver = std.mem.trim(u8, ver_result.stdout, " \n\r");
337+
try stdout.print("Active Zig: {s} ({s})\n", .{ active, ver });
338+
try stdout.flush();
339+
}
340+
}
341+
320342
// Clean up the downloaded archive
321343
std.Io.Dir.cwd().deleteFile(zvm.io, archive_path) catch {};
322344
}

0 commit comments

Comments
 (0)