Skip to content
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

Rename Dart env variable for post processing file #1101

Merged
merged 1 commit into from
Sep 25, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ public String getHelp() {
public void processOpts() {
super.processOpts();

if (StringUtils.isEmpty(System.getenv("DART_FMT_PATH"))) {
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)");
if (StringUtils.isEmpty(System.getenv("DART_POST_PROCESS_FILE"))) {
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)) {
Expand Down Expand Up @@ -512,9 +512,9 @@ public void postProcessFile(File file, String fileType) {
return;
}

String dartFmtPath = System.getenv("DART_FMT_PATH");
if (StringUtils.isEmpty(dartFmtPath)) {
return; // skip if DART_FMT_PATH env variable is not defined
String dartPostProcessFile = System.getenv("DART_POST_PROCESS_FILE");
if (StringUtils.isEmpty(dartPostProcessFile)) {
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)
Expand All @@ -532,14 +532,15 @@ public void postProcessFile(File file, String fileType) {
// only process files with dart extension
if ("dart".equals(FilenameUtils.getExtension(file.toString()))) {
// currently only support "dartfmt -w yourcode.dart"
String command = dartFmtPath + " -w " + file.toString();
String command = dartPostProcessFile + " " + 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