Skip to content

Commit

Permalink
rename perl environment variable (OpenAPITools#1172)
Browse files Browse the repository at this point in the history
  • Loading branch information
wing328 authored Oct 4, 2018
1 parent 06d31cf commit b4d835f
Showing 1 changed file with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ public PerlClientCodegen() {
public void processOpts() {
super.processOpts();

if (StringUtils.isEmpty(System.getenv("PERLTIDY_PATH"))) {
LOGGER.info("Environment variable PERLTIDY_PATH not defined so the Perl code may not be properly formatted. To define it, try 'export PERLTIDY_PATH=/usr/local/bin/perltidy' (Linux/Mac)");
if (StringUtils.isEmpty(System.getenv("PERL_POST_PROCESS_FILE"))) {
LOGGER.info("Environment variable PERL_POST_PROCESS_FILE not defined so the Perl code may not be properly formatted. To define it, try 'export PERL_POST_PROCESS_FILE=/usr/local/bin/perltidy -b -bext=\"/\"' (Linux/Mac)");
}

if (additionalProperties.containsKey(MODULE_VERSION)) {
Expand Down Expand Up @@ -571,9 +571,9 @@ public void postProcessFile(File file, String fileType) {
return;
}

String perlTidyPath = System.getenv("PERLTIDY_PATH");
String perlTidyPath = System.getenv("PERL_POST_PROCESS_FILE");
if (StringUtils.isEmpty(perlTidyPath)) {
return; // skip if PERLTIDY_PATH env variable is not defined
return; // skip if PERL_POST_PROCESS_FILE env variable is not defined
}

// only process files with .t, .pm extension
Expand All @@ -583,11 +583,12 @@ public void postProcessFile(File file, String fileType) {
String command = perlTidyPath + " -b -bext='/' " + file.toString();
try {
Process p = Runtime.getRuntime().exec(command);
p.waitFor();
if (p.exitValue() != 0) {
LOGGER.error("Error running the command ({}). Exit code: {}", command, p.exitValue());
int exitValue = p.waitFor();
if (exitValue != 0) {
LOGGER.error("Error running the command ({}). Exit code: {}", command, exitValue);
} else {
LOGGER.info("Successfully executed: " + command);
}
LOGGER.info("Successfully executed: " + command);
} catch (Exception e) {
LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage());
}
Expand Down

0 comments on commit b4d835f

Please sign in to comment.