Skip to content

Commit

Permalink
fix stoud in wrapper messes with generating completions
Browse files Browse the repository at this point in the history
  • Loading branch information
NikkyAI committed Mar 15, 2021
1 parent 3c86542 commit f7818ec
Showing 1 changed file with 25 additions and 5 deletions.
30 changes: 25 additions & 5 deletions wrapper/src/main/java/voodoo/Wrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,29 @@
public class Wrapper {

public static void main(String[] args) throws URISyntaxException {
boolean generateCompletion = false;
for(String key : System.getenv().keySet()) {
if(key.startsWith("_") && key.endsWith("_COMPLETE")) {
generateCompletion = true;
break;
}
}
if(Arrays.stream(args).anyMatch((e) -> e.startsWith("--generate-completion="))) {
generateCompletion = true;
}
if(generateCompletion) {
System.setOut(new PrintStream(new OutputStream() {
@Override
public void write(int arg0) {}
}));
System.setErr(new PrintStream(new OutputStream() {
@Override
public void write(int arg0) {}
}));
}
Properties props = new Properties();
File propertiesFile = new File(new File(Wrapper.class.getProtectionDomain().getCodeSource().getLocation().toURI()).getParentFile(), "wrapper.properties");
System.err.printf("loading wrapper properties from %s%n", propertiesFile.getPath());
System.out.printf("loading wrapper properties from %s%n", propertiesFile.getPath());
if (!propertiesFile.exists()) {
System.err.println("cannot open file " + propertiesFile.getPath());
System.exit(-1);
Expand Down Expand Up @@ -77,7 +97,7 @@ private static void launch(
String artifact = distributionUrl.substring(distributionUrl.lastIndexOf('/'));
artifact = artifact.substring(0, artifact.lastIndexOf(".jar"));

System.err.printf("Downloading the %s binary...%n", artifact);
System.out.printf("Downloading the %s binary...%n", artifact);

// File lastFile = new File(binariesDir, artifact + ".last.jar");

Expand All @@ -99,7 +119,7 @@ private static void launch(
throw new IllegalStateException(String.format("binary %s does not exist", file.getPath()));
}
// Files.copy(file.toPath(), lastFile.toPath());
System.err.printf("Loaded %s%n", file.getPath());
System.out.printf("Loaded %s%n", file.getPath());
String java = Paths.get(System.getProperty("java.home"), "bin", "java").toFile().getPath();
File workingDir = new File(System.getProperty("user.dir"));

Expand All @@ -125,7 +145,7 @@ private static void launch(

String[] args = argsList.toArray(new String[0]);

System.err.printf("Executing %s", argsList.toString());
System.out.printf("Executing %s", argsList.toString());
int exitStatus = new ProcessBuilder(args)
.directory(workingDir)
.redirectOutput(ProcessBuilder.Redirect.INHERIT)
Expand Down Expand Up @@ -178,7 +198,7 @@ public static File download(
String fileMd5 = toHexString(createMD5(targetFile));

if (fileMd5.equalsIgnoreCase(md5)) {
System.err.println("cached file matched md5 hash");
System.out.println("cached file matched md5 hash");
return targetFile;
}
}
Expand Down

0 comments on commit f7818ec

Please sign in to comment.