-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
run_command for jobs with several destination_languages dont change %OUTFILE% variable #142
Comments
In the run_command.pm file, the $command variable is overwritten. You can fix this by changing sub process_then_block {
my ($self, $phase, $block, $file, $lang, $strref) = @_;
die "This plugin should only be used in 'after_save_localized_file' phase (current phase: '$phase')" unless $phase eq 'after_save_localized_file';
my $outfile = $self->{parent}->{engine}->get_full_output_path($file, $lang);
($_, my $outpath, $_) = fileparse($outfile); # this way $outpath will include the trailing delimiter
foreach my $command (@{$block->{command}}) {
# substitute %FILE% and target language-based macros
# with the full path to the saved file
$command = subst_macros($command, $file, $lang);
# substitute %OUTFILE% macro with the full path to the saved file
$command =~ s/%OUTFILE%/$outfile/sg;
# substitute %OUTPATH% macro with the full directory path
$command =~ s/%OUTPATH%/$outpath/sg;
die "After macro substitution, 'command' parameter evaluates to an empty string" if $command eq '';
print "RUN: $command\n";
system($command);
my $error_code = unpack 'c', pack 'C', $? >> 8; # error code
die "Exit code: $error_code\n" if $error_code != 0;
}
return (shift @_)->SUPER::process_then_block(@_);
} to sub process_then_block {
my ($self, $phase, $block, $file, $lang, $strref) = @_;
die "This plugin should only be used in 'after_save_localized_file' phase (current phase: '$phase')" unless $phase eq 'after_save_localized_file';
my $outfile = $self->{parent}->{engine}->get_full_output_path($file, $lang);
($_, my $outpath, $_) = fileparse($outfile); # this way $outpath will include the trailing delimiter
foreach my $command (@{$block->{command}}) {
# substitute %FILE% and target language-based macros
# with the full path to the saved file
my $runcmd = subst_macros($command, $file, $lang);
# substitute %OUTFILE% macro with the full path to the saved file
$runcmd =~ s/%OUTFILE%/$outfile/sg;
# substitute %OUTPATH% macro with the full directory path
$runcmd =~ s/%OUTPATH%/$outpath/sg;
die "After macro substitution, 'command' parameter evaluates to an empty string" if $runcmd eq '';
print "RUN: $runcmd\n";
system($runcmd);
my $error_code = unpack 'c', pack 'C', $? >> 8; # error code
die "Exit code: $error_code\n" if $error_code != 0;
}
return (shift @_)->SUPER::process_then_block(@_);
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
simple run_command plugin like this:
produce output:
The text was updated successfully, but these errors were encountered: