mirror of
https://github.com/ziglang/zig.git
synced 2026-01-20 14:25:16 +00:00
std.Build.Step.Fmt: display non-conforming files
When in --check mode, and files are found to not conform, emit them explicitly as step errors. Previously this stdout data was being ignored.
This commit is contained in:
parent
af7afbd08b
commit
eb8201afde
@ -37,9 +37,6 @@ pub fn create(owner: *std.Build, options: Options) *Fmt {
|
||||
}
|
||||
|
||||
fn make(step: *Step, prog_node: std.Progress.Node) !void {
|
||||
// zig fmt is fast enough that no progress is needed.
|
||||
_ = prog_node;
|
||||
|
||||
// TODO: if check=false, this means we are modifying source files in place, which
|
||||
// is an operation that could race against other operations also modifying source files
|
||||
// in place. In this case, this step should obtain a write lock while making those
|
||||
@ -68,5 +65,15 @@ fn make(step: *Step, prog_node: std.Progress.Node) !void {
|
||||
argv.appendAssumeCapacity(b.pathFromRoot(p));
|
||||
}
|
||||
|
||||
return step.evalChildProcess(argv.items);
|
||||
const run_result = try step.captureChildProcess(prog_node, argv.items);
|
||||
if (fmt.check) switch (run_result.term) {
|
||||
.Exited => |code| if (code != 0 and run_result.stdout.len != 0) {
|
||||
var it = std.mem.tokenizeScalar(u8, run_result.stdout, '\n');
|
||||
while (it.next()) |bad_file_name| {
|
||||
try step.addError("{s}: non-conforming formatting", .{bad_file_name});
|
||||
}
|
||||
},
|
||||
else => {},
|
||||
};
|
||||
try step.handleChildProcessTerm(run_result.term, null, argv.items);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user