summary refs log tree commit diff
path: root/pkgs/applications/editors/jetbrains/update.pl
diff options
context:
space:
mode:
authorVolth <volth@webmaster.ms>2017-06-22 19:08:19 +0000
committerVolth <volth@webmaster.ms>2017-06-22 19:08:19 +0000
commit7fa29f39d199553bd32b7514fe1f5441a20954de (patch)
tree1820a9190144ee0af0f608897b8dfd820c58ef78 /pkgs/applications/editors/jetbrains/update.pl
parent00101eb7c92f110c857d85f4dbd1a31fc10a668c (diff)
downloadnixpkgs-7fa29f39d199553bd32b7514fe1f5441a20954de.tar
nixpkgs-7fa29f39d199553bd32b7514fe1f5441a20954de.tar.gz
nixpkgs-7fa29f39d199553bd32b7514fe1f5441a20954de.tar.bz2
nixpkgs-7fa29f39d199553bd32b7514fe1f5441a20954de.tar.lz
nixpkgs-7fa29f39d199553bd32b7514fe1f5441a20954de.tar.xz
nixpkgs-7fa29f39d199553bd32b7514fe1f5441a20954de.tar.zst
nixpkgs-7fa29f39d199553bd32b7514fe1f5441a20954de.zip
a little simpification (use File::Slurp)
Diffstat (limited to 'pkgs/applications/editors/jetbrains/update.pl')
-rwxr-xr-xpkgs/applications/editors/jetbrains/update.pl27
1 files changed, 4 insertions, 23 deletions
diff --git a/pkgs/applications/editors/jetbrains/update.pl b/pkgs/applications/editors/jetbrains/update.pl
index ecdedca9e15..62943787111 100755
--- a/pkgs/applications/editors/jetbrains/update.pl
+++ b/pkgs/applications/editors/jetbrains/update.pl
@@ -1,30 +1,11 @@
 #!/usr/bin/env nix-shell
-#!nix-shell -i perl -p perl perlPackages.LWPProtocolhttps
+#!nix-shell -i perl -p perl perlPackages.LWPProtocolhttps perlPackages.FileSlurp
 
 use strict;
 use List::Util qw(reduce);
-use File::Basename qw(dirname);
+use File::Slurp;
 use LWP::Simple;
 
-sub readFile {
-  my ($filename) = @_;
-  local $/ = undef;
-  open FILE, $filename or die "readFile($filename) failed: $!";
-  binmode FILE;
-  my $data = <FILE>;
-  close FILE;
-  return $data;
-}
-
-sub writeFile {
-  my ($filename, $content) = @_;
-  make_path(dirname($filename)) or die "$!" unless -d dirname($filename);
-  open FH, ">$filename" or die "writeFile($filename) failed: $!";
-  binmode FH; # do not emit \r
-  print FH $content;
-  close FH;
-}
-
 sub semantic_less {
   my ($a, $b) = @_;
   $a =~ s/\b(\d+)\b/sprintf("%010s", $1)/eg;
@@ -88,6 +69,6 @@ sub update_nix_block {
   return $block;
 }
 
-my $nix = readFile 'default.nix';
+my $nix = read_file 'default.nix';
 $nix =~ s/(= build\w+ rec \{.+?\};\n\n)/update_nix_block($1)/gse;
-writeFile 'default.nix', $nix;
+write_file 'default.nix', $nix;