Skip to content

Commit 20db016

Browse files
committed
rewrite read file process.
1 parent 6d8b3fc commit 20db016

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

tool/gen_mackerel_check.pl

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,18 @@
33
use warnings;
44
use utf8;
55
use autodie;
6+
use IO::File;
67
use JSON::PP;
78

8-
my $json = do {
9+
# file utility
10+
sub slurp_utf8 {
11+
my $filename = shift;
12+
my $fh = IO::File->new($filename, "<:utf8");
913
local $/;
10-
open my $fh, '<', 'packaging/config.json';
11-
<$fh>
12-
};
14+
<$fh>;
15+
}
1316

14-
my @plugins = sort @{ decode_json($json)->{plugins}};
17+
my @plugins = sort @{ decode_json(slurp_utf8('packaging/config.json'))->{plugins}};
1518

1619
my $imports = "";
1720
my $case = "";

0 commit comments

Comments
 (0)