| 1 | package Code::TidyAll::Plugin::JSBeautifier; | ||
| 2 | |||
| 3 | use File::Slurp::Tiny qw(write_file); | ||
| 4 | use IPC::Run3 qw(run3); | ||
| 5 | use Moo; | ||
| 6 | use Try::Tiny; | ||
| 7 | extends 'Code::TidyAll::Plugin'; | ||
| 8 | |||
| 9 | our $VERSION = '0.21'; | ||
| 10 | |||
| 11 | sub _build_cmd {'js_beautify.pl'} | ||
| 12 | |||
| 13 | sub transform_file { | ||
| 14 | my ( $self, $file ) = @_; | ||
| 15 | |||
| 16 | try { | ||
| 17 | my $cmd = join( " ", $self->cmd, '-o', $self->argv, $file ); | ||
| 18 | |||
| 19 | my $output; | ||
| 20 | run3( $cmd, \undef, \$output, \$output ); | ||
| 21 | #write_file( $file, $output ); | ||
| 22 | } | ||
| 23 | catch { | ||
| 24 | die sprintf( | ||
| 25 | "%s exited with error - possibly bad arg list '%s'\n $_", $self->cmd, | ||
| 26 | $self->argv | ||
| 27 | ); | ||
| 28 | }; | ||
| 29 | } | ||
| 30 | |||
| 31 | 1; | ||
| 32 | |||
| 33 | # ABSTRACT: Use JavaScript::Beautifier with tidyall | ||
| 34 | |||
| 35 | __END__ |