zig fmt: still print the relative path
The previous commit made zig fmt print absolute paths; this commit keeps the absolute path resolution but still prints the relative paths to stdout.master
parent
fdff381a56
commit
41e17106cd
|
@ -15,8 +15,12 @@ pub const BufferedAtomicFile = struct {
|
|||
|
||||
/// TODO when https://github.com/ziglang/zig/issues/2761 is solved
|
||||
/// this API will not need an allocator
|
||||
/// TODO integrate this with Dir API
|
||||
pub fn create(allocator: *mem.Allocator, dest_path: []const u8) !*BufferedAtomicFile {
|
||||
pub fn create(
|
||||
allocator: *mem.Allocator,
|
||||
dir: fs.Dir,
|
||||
dest_path: []const u8,
|
||||
atomic_file_options: fs.Dir.AtomicFileOptions,
|
||||
) !*BufferedAtomicFile {
|
||||
var self = try allocator.create(BufferedAtomicFile);
|
||||
self.* = BufferedAtomicFile{
|
||||
.atomic_file = undefined,
|
||||
|
@ -26,7 +30,7 @@ pub const BufferedAtomicFile = struct {
|
|||
};
|
||||
errdefer allocator.destroy(self);
|
||||
|
||||
self.atomic_file = try fs.cwd().atomicFile(dest_path, .{});
|
||||
self.atomic_file = try dir.atomicFile(dest_path, atomic_file_options);
|
||||
errdefer self.atomic_file.deinit();
|
||||
|
||||
self.file_stream = self.atomic_file.file.outStream();
|
||||
|
|
|
@ -339,7 +339,7 @@ fn fmtPath(fmt: *Fmt, file_path: []const u8, check_mode: bool) FmtError!void {
|
|||
|
||||
while (try dir_it.next()) |entry| {
|
||||
if (entry.kind == .Directory or mem.endsWith(u8, entry.name, ".zig")) {
|
||||
const full_path = try fs.path.join(fmt.allocator, &[_][]const u8{ real_path, entry.name });
|
||||
const full_path = try fs.path.join(fmt.allocator, &[_][]const u8{ file_path, entry.name });
|
||||
try fmtPath(fmt, full_path, check_mode);
|
||||
}
|
||||
}
|
||||
|
@ -377,7 +377,7 @@ fn fmtPath(fmt: *Fmt, file_path: []const u8, check_mode: bool) FmtError!void {
|
|||
fmt.any_error = true;
|
||||
}
|
||||
} else {
|
||||
const baf = try io.BufferedAtomicFile.create(fmt.allocator, real_path);
|
||||
const baf = try io.BufferedAtomicFile.create(fmt.allocator, fs.cwd(), real_path, .{});
|
||||
defer baf.destroy();
|
||||
|
||||
const anything_changed = try std.zig.render(fmt.allocator, baf.stream(), tree);
|
||||
|
|
Loading…
Reference in New Issue