Add javascript indenter
This commit is contained in:
parent
1487e055a7
commit
be919274c2
3
Makefile
3
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*/ -type f \( -name '*.pm' -or -name '*.pl' -or -name '*.t' \) -print -exec perltidy -b {} \;
|
||||||
find lemon*/ -name '*.bak' -delete
|
find lemon*/ -name '*.bak' -delete
|
||||||
|
|
||||||
|
tidy-js: clean
|
||||||
|
find lemon*/ -type f -name '*.js' ! -name 'jq*' -print -exec scripts/javascript-indent {} \;
|
||||||
|
|
||||||
|
|
19
scripts/javascript-indent
Executable file
19
scripts/javascript-indent
Executable file
|
@ -0,0 +1,19 @@
|
||||||
|
#!/usr/bin/perl -w
|
||||||
|
|
||||||
|
use JavaScript::Beautifier qw/js_beautify/;
|
||||||
|
|
||||||
|
unless ( $ARGV[0] and -e $ARGV[0] ) {
|
||||||
|
die "Usage $0 <file.js>";
|
||||||
|
}
|
||||||
|
|
||||||
|
open F, $ARGV[0] or die($!);
|
||||||
|
my $src;
|
||||||
|
while (<F>) { $src .= $_; }
|
||||||
|
close F;
|
||||||
|
|
||||||
|
open F, ">",$ARGV[0] or die($!);
|
||||||
|
|
||||||
|
print F js_beautify( $src, {
|
||||||
|
indent_size => 1, indent_character => "\t", preserve_newlines => 1 }
|
||||||
|
);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user