Lines 184-196
sub tidy_tt {
Link Here
|
184 |
my ( $success, $error_message, $full_buf, $stdout_buf, $stderr_buf ); |
184 |
my ( $success, $error_message, $full_buf, $stdout_buf, $stderr_buf ); |
185 |
|
185 |
|
186 |
my ( $file_fh, $file ); # Keep this scope for $file_fh, or the file will be deleted after the following block |
186 |
my ( $file_fh, $file ); # Keep this scope for $file_fh, or the file will be deleted after the following block |
187 |
if ($no_write) { |
187 |
$file_fh = File::Temp->new( CLEANUP => 1, SUFFIX => '.tt', DIR => '.' ); |
188 |
$file_fh = File::Temp->new( CLEANUP => 1, SUFFIX => '.tt', DIR => '.' ); |
188 |
$file = $file_fh->filename; |
189 |
$file = $file_fh->filename; |
189 |
write_file( $file, read_file($original_file) ); |
190 |
write_file( $file, read_file($original_file) ); |
|
|
191 |
} else { |
192 |
$file = $original_file; |
193 |
} |
194 |
|
190 |
|
195 |
for my $pass ( 1 .. 2 ) { |
191 |
for my $pass ( 1 .. 2 ) { |
196 |
( $success, $error_message, $full_buf, $stdout_buf, $stderr_buf ) = |
192 |
( $success, $error_message, $full_buf, $stdout_buf, $stderr_buf ) = |
Lines 207-214
sub tidy_tt {
Link Here
|
207 |
$content =~ s#\n*( *)</script>\n*#\n$1</script>\n#g; |
203 |
$content =~ s#\n*( *)</script>\n*#\n$1</script>\n#g; |
208 |
$content =~ s#(\[%\s*SWITCH[^\]]*\]\n)\n#$1#g; |
204 |
$content =~ s#(\[%\s*SWITCH[^\]]*\]\n)\n#$1#g; |
209 |
|
205 |
|
|
|
206 |
unless ($content) { |
207 |
return ( 0, "Something went wrong, Prettier generated an empty file.", [], [], [] ); |
208 |
} |
210 |
if ( $no_write && $pass == 2 ) { |
209 |
if ( $no_write && $pass == 2 ) { |
211 |
print $content; |
210 |
print $content; |
|
|
211 |
} elsif ( $pass == 2 ) { |
212 |
write_file( $original_file, $content ); |
212 |
} else { |
213 |
} else { |
213 |
write_file( $file, $content ); |
214 |
write_file( $file, $content ); |
214 |
} |
215 |
} |
215 |
- |
|
|