]>
Raphaël G. Git Repositories - binary/blob - jpack
   8 use POSIX 
qw(EXIT_SUCCESS EXIT_FAILURE); 
  11 use JavaScript
::Packer
; 
  14 my $compress = 'best'; #clean, shrink, obfuscate or best 
  16 #TODO: see how to handle theses options in a hash 
  21 # Init remove_copyright 
  22 my $remove_copyright = 1; 
  24 # Init no_compress_comment 
  25 my $no_compress_comment = 1; 
  28 @ARGV = map { if ($_ eq '-c' || $_ eq '--clean') { $compress = 'clean'; (); } elsif ($_ eq '-s' || $_ eq '--shrink') { $compress = 'shrink'; (); } elsif ($_ eq '-o' || $_ eq '--obfuscate') { $compress = 'obfuscate'; (); } elsif ($_ eq '-b' || $_ eq '--best') { $compress = 'best'; (); } else { $_; } } @ARGV; 
  30 # Show usage with invalid argument or stdin opened to a tty 
  31 if (scalar(@ARGV) || -t STDIN
) { 
  32         print "Usage: $0 [-c|--clean|-s|--shrink|-o|--obfuscate|-b|--best] < input.js > output.js\n"; 
  36 # Instantiate packer object 
  37 my $packer = JavaScript
::Packer-
>init(); 
  39 # Load input in variable 
  40 my $input = do { local $/; <STDIN
> }; 
  42 # Minify input with required compression 
  43 $packer->minify(\
$input, { copyright 
=> $copyright, remove_copyright 
=> $remove_copyright, no_compress_comment 
=> $no_compress_comment, compress 
=> $compress }); 
  55 Jpack - A simple perl JavaScript minifier 
  63 A fast pure Perl JavaScript minifier script. 
  67 Raphaël Gertz (Rapsys) << <git at rapsys.eu> >>. 
  69 =head1 COPYRIGHT & LICENSE 
  71 Copyright 2016 - 2017 Raphaël Gertz, all rights reserved. 
  73 This program is free software: you can redistribute it and/or modify 
  74 it under the terms of the GNU General Public License as published by 
  75 the Free Software Foundation, either version 3 of the License, or 
  76 (at your option) any later version. 
  78 This program is distributed in the hope that it will be useful, 
  79 but WITHOUT ANY WARRANTY; without even the implied warranty of 
  80 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
  81 GNU General Public License for more details. 
  83 You should have received a copy of the GNU General Public License 
  84 along with this program.  If not, see <http://www.gnu.org/licenses/>.