GitHubPulls: output sorted json without using jq

This commit is contained in:
Graham Christensen 2021-10-12 14:22:32 -04:00
parent 2ee584e7ae
commit 3c38629fad

View file

@ -53,11 +53,12 @@ sub fetchInput {
_iterate("https://api.github.com/repos/$owner/$repo/pulls?per_page=100", $auth, \%pulls, $ua);
my $tempdir = File::Temp->newdir("github-pulls" . "XXXXX", TMPDIR => 1);
my $filename = "$tempdir/github-pulls.json";
open(my $fh, ">", $filename) or die "Cannot open $filename for writing: $!";
print $fh encode_json \%pulls;
print $fh JSON->new->utf8->canonical->encode(\%pulls);
close $fh;
system("jq -S . < $filename > $tempdir/github-pulls-sorted.json");
my $storePath = trim(`nix-store --add "$tempdir/github-pulls-sorted.json"`
my $storePath = trim(`nix-store --add "$filename"`
or die "cannot copy path $filename to the Nix store.\n");
chomp $storePath;
my $timestamp = time;