r49580 - in /branches/upstream/libjavascript-beautifier-perl/current: Build.PL Changes META.yml Makefile.PL bin/js_beautify.pl lib/JavaScript/Beautifier.pm t/01-javascript-beauty.t

jawnsy-guest at users.alioth.debian.org jawnsy-guest at users.alioth.debian.org
Thu Dec 31 04:23:41 UTC 2009


Author: jawnsy-guest
Date: Thu Dec 31 04:23:33 2009
New Revision: 49580

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=49580
Log:
[svn-upgrade] Integrating new upstream version, libjavascript-beautifier-perl (0.17)

Modified:
    branches/upstream/libjavascript-beautifier-perl/current/Build.PL
    branches/upstream/libjavascript-beautifier-perl/current/Changes
    branches/upstream/libjavascript-beautifier-perl/current/META.yml
    branches/upstream/libjavascript-beautifier-perl/current/Makefile.PL
    branches/upstream/libjavascript-beautifier-perl/current/bin/js_beautify.pl
    branches/upstream/libjavascript-beautifier-perl/current/lib/JavaScript/Beautifier.pm
    branches/upstream/libjavascript-beautifier-perl/current/t/01-javascript-beauty.t

Modified: branches/upstream/libjavascript-beautifier-perl/current/Build.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjavascript-beautifier-perl/current/Build.PL?rev=49580&op=diff
==============================================================================
--- branches/upstream/libjavascript-beautifier-perl/current/Build.PL (original)
+++ branches/upstream/libjavascript-beautifier-perl/current/Build.PL Thu Dec 31 04:23:33 2009
@@ -11,6 +11,7 @@
         'Test::More' => '0.88',
         'Getopt::Long' => 0,
         'Pod::Usage' => 0,
+        'IO::File' => 0,
     },
     add_to_cleanup      => [ 'JavaScript-Beautifier-*' ],
     create_makefile_pl => 'traditional',

Modified: branches/upstream/libjavascript-beautifier-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjavascript-beautifier-perl/current/Changes?rev=49580&op=diff
==============================================================================
--- branches/upstream/libjavascript-beautifier-perl/current/Changes (original)
+++ branches/upstream/libjavascript-beautifier-perl/current/Changes Thu Dec 31 04:23:33 2009
@@ -1,4 +1,8 @@
 Revision history for JavaScript-Beautifier
+
+0.17    2009.12.30
+        Allex Wang's fix for else { if handling
+        js_beautify.pl [options] - (from STDIN) (RT 53220)
 
 0.16    2009.09.22
         Fixed array indentation regressions.

Modified: branches/upstream/libjavascript-beautifier-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjavascript-beautifier-perl/current/META.yml?rev=49580&op=diff
==============================================================================
--- branches/upstream/libjavascript-beautifier-perl/current/META.yml (original)
+++ branches/upstream/libjavascript-beautifier-perl/current/META.yml Thu Dec 31 04:23:33 2009
@@ -1,6 +1,6 @@
 ---
 name: JavaScript-Beautifier
-version: 0.16
+version: 0.17
 author:
   - 'Fayland Lam <fayland at gmail.com>'
 abstract: Beautify Javascript (beautifier for javascript)
@@ -10,6 +10,7 @@
   repository: http://github.com/fayland/perl-javascript-beautifier/tree/master
 build_requires:
   Getopt::Long: 0
+  IO::File: 0
   Pod::Usage: 0
   Test::More: 0.88
 configure_requires:
@@ -17,7 +18,7 @@
 provides:
   JavaScript::Beautifier:
     file: lib/JavaScript/Beautifier.pm
-    version: 0.16
+    version: 0.17
 generated_by: Module::Build version 0.35
 meta-spec:
   url: http://module-build.sourceforge.net/META-spec-v1.4.html

Modified: branches/upstream/libjavascript-beautifier-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjavascript-beautifier-perl/current/Makefile.PL?rev=49580&op=diff
==============================================================================
--- branches/upstream/libjavascript-beautifier-perl/current/Makefile.PL (original)
+++ branches/upstream/libjavascript-beautifier-perl/current/Makefile.PL Thu Dec 31 04:23:33 2009
@@ -6,6 +6,7 @@
           'VERSION_FROM' => 'lib/JavaScript/Beautifier.pm',
           'PREREQ_PM' => {
                            'Getopt::Long' => '0',
+                           'IO::File' => '0',
                            'Pod::Usage' => '0',
                            'Test::More' => '0.88'
                          },

Modified: branches/upstream/libjavascript-beautifier-perl/current/bin/js_beautify.pl
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjavascript-beautifier-perl/current/bin/js_beautify.pl?rev=49580&op=diff
==============================================================================
--- branches/upstream/libjavascript-beautifier-perl/current/bin/js_beautify.pl (original)
+++ branches/upstream/libjavascript-beautifier-perl/current/bin/js_beautify.pl Thu Dec 31 04:23:33 2009
@@ -5,10 +5,11 @@
 use JavaScript::Beautifier qw/js_beautify/;
 use Getopt::Long;
 use Pod::Usage;
+use IO::File;
+use Carp qw/croak/;
 
 my $file = pop @ARGV;
 pod2usage(1) unless ($file);
-die "$! - $file" unless -f $file;
 
 my %params;
 GetOptions(
@@ -23,10 +24,17 @@
 
 pod2usage(1) if $params{help};
 
-open(my $fh, '<', $file);
+my $file_io;
+if ($file eq '-') {
+    my $io = new IO::Handle;
+    $file_io = $io->fdopen(fileno(STDIN),"r");
+} else {
+    $file_io = new IO::File($file, "<");
+    defined $file_io or croak "can't open $file: $!";
+}
 local $/;
-my $js_source_code = <$fh>;
-close($fh);
+my $js_source_code = <$file_io>;
+$file_io->close;
 
 my $pretty_js = js_beautify( $js_source_code, {
     indent_size => $params{s} || 4,
@@ -53,6 +61,7 @@
 =head1 SYNOPSIS
 
     js_beautify.pl [options] FILE
+    js_beautify.pl [options] -
 
 =head1 OPTIONS
 

Modified: branches/upstream/libjavascript-beautifier-perl/current/lib/JavaScript/Beautifier.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjavascript-beautifier-perl/current/lib/JavaScript/Beautifier.pm?rev=49580&op=diff
==============================================================================
--- branches/upstream/libjavascript-beautifier-perl/current/lib/JavaScript/Beautifier.pm (original)
+++ branches/upstream/libjavascript-beautifier-perl/current/lib/JavaScript/Beautifier.pm Thu Dec 31 04:23:33 2009
@@ -3,7 +3,7 @@
 use warnings;
 use strict;
 
-our $VERSION = '0.16';
+our $VERSION = '0.17';
 our $AUTHORITY = 'cpan:FAYLAND';
 
 use base 'Exporter';
@@ -217,7 +217,7 @@
                 } elsif ( $last_type ne 'TK_END_EXPR' ) {
                     if ( ($last_type ne 'TK_START_EXPR' || $token_text ne 'var') && $last_text ne ':' ) {
                         # no need to force newline on 'var': for (var x = 0...)
-                        if ( $token_text eq 'if' && $last_word eq 'else' ) {
+                        if ( $token_text eq 'if' && $last_word eq 'else' && $last_text ne '{' ) {
                             # no newline for } else if {
                             print_space();
                         }  else {

Modified: branches/upstream/libjavascript-beautifier-perl/current/t/01-javascript-beauty.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjavascript-beautifier-perl/current/t/01-javascript-beauty.t?rev=49580&op=diff
==============================================================================
--- branches/upstream/libjavascript-beautifier-perl/current/t/01-javascript-beauty.t (original)
+++ branches/upstream/libjavascript-beautifier-perl/current/t/01-javascript-beauty.t Thu Dec 31 04:23:33 2009
@@ -217,6 +217,7 @@
 bt( 'var o2=$.extend(a,function(){alert(x);}', "var o2 = \$.extend(a, function() {\n    alert(x);\n}");
 bt( 'var o2=$.extend(a);function(){alert(x);}', "var o2 = \$.extend(a);\nfunction() {\n    alert(x);\n}");
 bt( '{[y[a]];keep_indent;}', "{\n    [y[a]];\n    keep_indent;\n}");
+bt( 'if (x) {y} else { if (x) {y}}', "if (x) {\n    y\n} else {\n    if (x) {\n        y\n    }\n}" );
 
 $opts->{indent_size} = 1;
 $opts->{indent_char} = ' ';




More information about the Pkg-perl-cvs-commits mailing list