From be919274c26f8b1285e32ea4b89b75574a79f4a5 Mon Sep 17 00:00:00 2001 From: Xavier Guimard Date: Wed, 30 Oct 2013 19:44:09 +0000 Subject: [PATCH] Add javascript indenter --- Makefile | 3 +++ scripts/javascript-indent | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100755 scripts/javascript-indent diff --git a/Makefile b/Makefile index 30e17a2cd..871a6e4fc 100644 --- a/Makefile +++ b/Makefile @@ -686,3 +686,6 @@ tidy: clean find lemon*/ -type f \( -name '*.pm' -or -name '*.pl' -or -name '*.t' \) -print -exec perltidy -b {} \; find lemon*/ -name '*.bak' -delete +tidy-js: clean + find lemon*/ -type f -name '*.js' ! -name 'jq*' -print -exec scripts/javascript-indent {} \; + diff --git a/scripts/javascript-indent b/scripts/javascript-indent new file mode 100755 index 000000000..e1240b2a4 --- /dev/null +++ b/scripts/javascript-indent @@ -0,0 +1,19 @@ +#!/usr/bin/perl -w + +use JavaScript::Beautifier qw/js_beautify/; + +unless ( $ARGV[0] and -e $ARGV[0] ) { + die "Usage $0 "; +} + +open F, $ARGV[0] or die($!); +my $src; +while () { $src .= $_; } +close F; + +open F, ">",$ARGV[0] or die($!); + +print F js_beautify( $src, { + indent_size => 1, indent_character => "\t", preserve_newlines => 1 } +); +