Remove unnecessary Output.flushs before Global.exit and Global.crash (#535)

* fix: add missing newline

* refactor: std.process.exit -> Global.exit

* fix: std.os.abort -> Global.exit

I'm not sure about this one. Please verify.

* cleanup: remove unnecessary `Output.flush`s
This commit is contained in:
r00ster91
2022-07-10 15:44:57 +02:00
committed by GitHub
parent 05970fe1fb
commit 16452c16da
19 changed files with 4 additions and 137 deletions

View File

@@ -418,7 +418,6 @@ pub const CreateCommand = struct {
const examples = try Example.fetchAllLocalAndRemote(ctx, null, &env_loader, filesystem);
Example.print(examples.items, dirname);
Output.flush();
Global.exit(1);
},
else => {
@@ -532,7 +531,6 @@ pub const CreateCommand = struct {
}
Output.prettyErrorln("<r>\n<d>To download {s} anyway, use --force<r>", .{template});
Output.flush();
Global.exit(1);
}
}
@@ -571,7 +569,6 @@ pub const CreateCommand = struct {
progress.refresh();
Output.prettyErrorln("<r><red>{s}<r>: opening dir {s}", .{ @errorName(err), template });
Output.flush();
Global.exit(1);
};
@@ -582,7 +579,6 @@ pub const CreateCommand = struct {
progress.refresh();
Output.prettyErrorln("<r><red>{s}<r>: creating dir {s}", .{ @errorName(err), destination });
Output.flush();
Global.exit(1);
};
@@ -610,7 +606,6 @@ pub const CreateCommand = struct {
progress_.refresh();
Output.prettyErrorln("<r><red>{s}<r>: copying file {s}", .{ @errorName(err), entry.path });
Output.flush();
Global.exit(1);
};
};
@@ -631,7 +626,6 @@ pub const CreateCommand = struct {
progress_.refresh();
Output.prettyErrorln("<r><red>{s}<r>: copying file {s}", .{ @errorName(err), entry.path });
Output.flush();
Global.exit(1);
};
};
@@ -1876,11 +1870,9 @@ pub const Example = struct {
if (content_type.len > 0) {
Output.prettyErrorln("<r><red>error<r>: Unexpected content type from GitHub: {s}", .{content_type});
Output.flush();
Global.crash();
} else {
Output.prettyErrorln("<r><red>error<r>: Invalid response from GitHub (missing content type)", .{});
Output.flush();
Global.crash();
}
}
@@ -1890,7 +1882,6 @@ pub const Example = struct {
refresher.refresh();
Output.prettyErrorln("<r><red>error<r>: Invalid response from GitHub (missing body)", .{});
Output.flush();
Global.crash();
}
@@ -1937,11 +1928,9 @@ pub const Example = struct {
} else {
try ctx.log.printForLogLevelWithEnableAnsiColors(Output.errorWriter(), false);
}
Output.flush();
Global.exit(1);
} else {
Output.prettyErrorln("Error parsing package: <r><red>{s}<r>", .{@errorName(err)});
Output.flush();
Global.exit(1);
}
};
@@ -1955,7 +1944,6 @@ pub const Example = struct {
} else {
try ctx.log.printForLogLevelWithEnableAnsiColors(Output.errorWriter(), false);
}
Output.flush();
Global.exit(1);
}
@@ -1974,7 +1962,6 @@ pub const Example = struct {
refresher.refresh();
Output.prettyErrorln("package.json is missing tarball url. This is an internal error!", .{});
Output.flush();
Global.exit(1);
};
@@ -1999,7 +1986,6 @@ pub const Example = struct {
progress.end();
refresher.refresh();
Output.prettyErrorln("Error fetching tarball: <r><red>{d}<r>", .{response.status_code});
Output.flush();
Global.exit(1);
}
@@ -2026,12 +2012,10 @@ pub const Example = struct {
switch (err) {
error.WouldBlock => {
Output.prettyErrorln("Request timed out while trying to fetch examples list. Please try again", .{});
Output.flush();
Global.exit(1);
},
else => {
Output.prettyErrorln("<r><red>{s}<r> while trying to fetch examples list. Please try again", .{@errorName(err)});
Output.flush();
Global.exit(1);
},
}
@@ -2039,7 +2023,6 @@ pub const Example = struct {
if (response.status_code != 200) {
Output.prettyErrorln("<r><red>{d}<r> fetching examples :( {s}", .{ response.status_code, mutable.list.items });
Output.flush();
Global.exit(1);
}
@@ -2053,10 +2036,8 @@ pub const Example = struct {
try ctx.log.printForLogLevelWithEnableAnsiColors(Output.errorWriter(), false);
}
Global.exit(1);
Output.flush();
} else {
Output.prettyErrorln("Error parsing examples: <r><red>{s}<r>", .{@errorName(err)});
Output.flush();
Global.exit(1);
}
};
@@ -2067,7 +2048,6 @@ pub const Example = struct {
} else {
try ctx.log.printForLogLevelWithEnableAnsiColors(Output.errorWriter(), false);
}
Output.flush();
Global.exit(1);
}
@@ -2092,7 +2072,6 @@ pub const Example = struct {
}
Output.prettyErrorln("Corrupt examples data: expected object but received {s}", .{@tagName(examples_object.data)});
Output.flush();
Global.exit(1);
}
};
@@ -2150,7 +2129,6 @@ const GitHandler = struct {
thread = std.Thread.spawn(.{}, spawnThread, .{ destination, PATH, verbose }) catch |err| {
Output.prettyErrorln("<r><red>{s}<r>", .{@errorName(err)});
Output.flush();
Global.exit(1);
};
}