Merge branch 'handle-empty-filenames'
All checks were successful
AWS-Zig Build / build-zig-amd64-host (push) Successful in 7m52s
All checks were successful
AWS-Zig Build / build-zig-amd64-host (push) Successful in 7m52s
This commit is contained in:
commit
bc18fcca75
1 changed files with 9 additions and 15 deletions
|
@ -209,27 +209,21 @@ fn processFile(file_name: []const u8, output_dir: std.fs.Dir, manifest: anytype)
|
||||||
_ = try writer.write("\n");
|
_ = try writer.write("\n");
|
||||||
_ = try writer.write("const serializeMap = json.serializeMap;\n");
|
_ = try writer.write("const serializeMap = json.serializeMap;\n");
|
||||||
_ = try writer.write("\n");
|
_ = try writer.write("\n");
|
||||||
|
|
||||||
if (verbose) std.log.info("Processing file: {s}", .{file_name});
|
if (verbose) std.log.info("Processing file: {s}", .{file_name});
|
||||||
|
|
||||||
const service_names = generateServicesForFilePath(allocator, ";", file_name, writer) catch |err| {
|
const service_names = generateServicesForFilePath(allocator, ";", file_name, writer) catch |err| {
|
||||||
std.log.err("Error processing file: {s}", .{file_name});
|
std.log.err("Error processing file: {s}", .{file_name});
|
||||||
return err;
|
return err;
|
||||||
};
|
};
|
||||||
defer {
|
|
||||||
for (service_names) |name| allocator.free(name);
|
var output_file_name: []const u8 = try std.mem.join(allocator, "-", service_names);
|
||||||
allocator.free(service_names);
|
|
||||||
}
|
if (output_file_name.len == 0) {
|
||||||
var output_file_name = try std.fmt.allocPrint(allocator, "", .{});
|
const ext = std.fs.path.extension(file_name);
|
||||||
defer allocator.free(output_file_name);
|
output_file_name = file_name[0 .. file_name.len - ext.len];
|
||||||
for (service_names) |name| {
|
|
||||||
const seperator = if (output_file_name.len > 0) "-" else "";
|
|
||||||
const new_output_file_name = try std.fmt.allocPrint(
|
|
||||||
allocator,
|
|
||||||
"{s}{s}{s}",
|
|
||||||
.{ output_file_name, seperator, name },
|
|
||||||
);
|
|
||||||
allocator.free(output_file_name);
|
|
||||||
output_file_name = new_output_file_name;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// append .zig on to the file name
|
// append .zig on to the file name
|
||||||
const new_output_file_name = try std.fmt.allocPrint(
|
const new_output_file_name = try std.fmt.allocPrint(
|
||||||
|
|
Loading…
Add table
Reference in a new issue