mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-07-03 06:00:52 +00:00
rename dart env variable for post processing file (#1101)
This commit is contained in:
parent
df61cd9cb3
commit
cd8bf10b74
@ -150,8 +150,8 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
public void processOpts() {
|
public void processOpts() {
|
||||||
super.processOpts();
|
super.processOpts();
|
||||||
|
|
||||||
if (StringUtils.isEmpty(System.getenv("DART_FMT_PATH"))) {
|
if (StringUtils.isEmpty(System.getenv("DART_POST_PROCESS_FILE"))) {
|
||||||
LOGGER.info("Environment variable DART_FMT_PATH not defined so the Dart code may not be properly formatted. To define it, try 'export DART_FMT_PATH=/usr/local/bin/dartfmt' (Linux/Mac)");
|
LOGGER.info("Environment variable DART_POST_PROCESS_FILE not defined so the Dart code may not be properly formatted. To define it, try `export DART_POST_PROCESS_FILE=\"/usr/local/bin/dartfmt -w\"` (Linux/Mac)");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (additionalProperties.containsKey(BROWSER_CLIENT)) {
|
if (additionalProperties.containsKey(BROWSER_CLIENT)) {
|
||||||
@ -512,9 +512,9 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String dartFmtPath = System.getenv("DART_FMT_PATH");
|
String dartPostProcessFile = System.getenv("DART_POST_PROCESS_FILE");
|
||||||
if (StringUtils.isEmpty(dartFmtPath)) {
|
if (StringUtils.isEmpty(dartPostProcessFile)) {
|
||||||
return; // skip if DART_FMT_PATH env variable is not defined
|
return; // skip if DART_POST_PROCESS_FILE env variable is not defined
|
||||||
}
|
}
|
||||||
|
|
||||||
// only procees the following type (or we can simply rely on the file extension to check if it's a Dart file)
|
// only procees the following type (or we can simply rely on the file extension to check if it's a Dart file)
|
||||||
@ -532,14 +532,15 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
// only process files with dart extension
|
// only process files with dart extension
|
||||||
if ("dart".equals(FilenameUtils.getExtension(file.toString()))) {
|
if ("dart".equals(FilenameUtils.getExtension(file.toString()))) {
|
||||||
// currently only support "dartfmt -w yourcode.dart"
|
// currently only support "dartfmt -w yourcode.dart"
|
||||||
String command = dartFmtPath + " -w " + file.toString();
|
String command = dartPostProcessFile + " " + file.toString();
|
||||||
try {
|
try {
|
||||||
Process p = Runtime.getRuntime().exec(command);
|
Process p = Runtime.getRuntime().exec(command);
|
||||||
p.waitFor();
|
int exitValue = p.waitFor();
|
||||||
if (p.exitValue() != 0) {
|
if (exitValue != 0) {
|
||||||
LOGGER.error("Error running the command ({}). Exit code: {}", command, p.exitValue());
|
LOGGER.error("Error running the command ({}). Exit code: {}", command, exitValue);
|
||||||
|
} else {
|
||||||
|
LOGGER.info("Successfully executed: " + command);
|
||||||
}
|
}
|
||||||
LOGGER.info("Successfully executed: " + command);
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage());
|
LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage());
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user