remove-console-asserts.pl 774 B

1234567891011121314151617181920212223242526272829303132
  1. #!/usr/bin/perl -w
  2. use strict;
  3. use Getopt::Long;
  4. use File::Copy qw/move/;
  5. use File::Temp qw/tempfile/;
  6. our $inputScriptFilename;
  7. our $outputScriptFilename;
  8. GetOptions('input-script=s' => \$inputScriptFilename,
  9. 'output-script=s' => \$outputScriptFilename);
  10. unless (defined $inputScriptFilename and defined $outputScriptFilename) {
  11. print "Usage: $0 --input-script <path> --output-script <path>\n";
  12. exit;
  13. }
  14. open IN, $inputScriptFilename or die;
  15. our ($out, $tempFilename) = tempfile(UNLINK => 0) or die;
  16. while (<IN>) {
  17. s/\s*console\.assert\(.*\);\s*//g;
  18. print $out $_;
  19. print "WARNING: Multi-line console.assert on line $.: $_" if $_ =~ /\s*console\.assert\(/;
  20. }
  21. close $out;
  22. close IN;
  23. move $tempFilename, $outputScriptFilename or die "$!";