Created
July 24, 2011 14:52
-
-
Save fcamel/1102696 to your computer and use it in GitHub Desktop.
indent js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
use JavaScript::Beautifier qw/js_beautify/; | |
if ($#ARGV != 1) { | |
print "jsindent <in file> <out file>\n"; | |
exit(1); | |
} | |
open(FR, $ARGV[0]) or die "can't open $ARGV[0]: $!"; | |
my @lines = <FR>; | |
close(FR); | |
my $js_source_code = join("\n", @lines); | |
my $pretty_js = js_beautify( $js_source_code, { | |
indent_size => 4, | |
indent_character => ' ', | |
} ); | |
open(FW, ">$ARGV[1]") or die "can't write to $ARGV[1]: $!"; | |
print FW $pretty_js; | |
close(FW); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment