Skip to content

Commit

Permalink
Fix errors related to slurping and spewing
Browse files Browse the repository at this point in the history
  • Loading branch information
bbrtj committed Jul 1, 2024
1 parent cc67c13 commit 192d540
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
Revision history for Kelp

{NEXT}
[Changes]
- Fixed config files having incorrect line endings on Windows due to raw slurp
- Fixed generation templates not handling UTF8 correctly

2.13 - 2024-07-01
[New Interface]
- Kelp::Base can now be imported with -attr
Expand Down
2 changes: 1 addition & 1 deletion bin/kelp-generator
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ for my $filedata (@$files) {
}

_say("Writing file: $filename");
$file->spew($contents);
$file->spew({binmode => ':encoding(UTF-8)'}, $contents);
}

sub _say {
Expand Down
2 changes: 1 addition & 1 deletion lib/Kelp/Generator.pm
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ sub get_template
$dest_file =~ s/DOT/./g;

# process the template, if it is .gen (generated)
my $contents = $file->slurp;
my $contents = $file->slurp({binmode => ':encoding(UTF-8)'});
if ($dest_file =~ /\.gen$/) {
$dest_file =~ s/\.gen$//;
$contents = $tt->process(\$contents, $vars);
Expand Down
2 changes: 1 addition & 1 deletion lib/Kelp/Module/Config.pm
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ sub load
# Open and read file
my $text;
try {
$text = path($filename)->slurp_utf8;
$text = path($filename)->slurp({binmode => ':encoding(UTF-8)'});
};

if (!defined $text) {
Expand Down

0 comments on commit 192d540

Please sign in to comment.