Skip to content

Commit

Permalink
Fix client not responding when using help with an output redirection, f…
Browse files Browse the repository at this point in the history
…ixes #519 (#521)
  • Loading branch information
gnodet committed Dec 6, 2021
1 parent a886562 commit ad70393
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Expand Up @@ -250,7 +250,12 @@ public ExecutionResult execute(ClientOutput output, List<String> argv) {
.or(() -> Optional.ofNullable(parameters.mavenRepoLocal()).map(Path::toString));
repo.ifPresent(r -> Environment.MAVEN_REPO_LOCAL.addCommandLineOption(args, r));

Environment.MVND_TERMINAL_WIDTH.addCommandLineOption(args, Integer.toString(output.getTerminalWidth()));
String width = Optional.ofNullable(Environment.MVND_TERMINAL_WIDTH.removeCommandLineOption(args))
.orElseGet(() -> {
int w = output.getTerminalWidth();
return Integer.toString(w > 0 ? Math.max(w, 80) : 120);
});
Environment.MVND_TERMINAL_WIDTH.addCommandLineOption(args, width);

Path dir;
if (Environment.MAVEN_FILE.hasCommandLineOption(args)) {
Expand Down
Expand Up @@ -35,6 +35,7 @@
import java.util.function.Consumer;
import java.util.stream.Collector;
import java.util.stream.Collectors;
import org.fusesource.jansi.internal.CLibrary;
import org.jline.terminal.Size;
import org.jline.terminal.Terminal;
import org.jline.terminal.TerminalBuilder;
Expand Down Expand Up @@ -147,7 +148,12 @@ public Project(String id) {

public TerminalOutput(boolean noBuffering, int rollingWindowSize, Path logFile) throws IOException {
this.start = System.currentTimeMillis();
this.terminal = TerminalBuilder.terminal();
TerminalBuilder builder = TerminalBuilder.builder();
boolean outRedirected = CLibrary.isatty(0) == 1 && CLibrary.isatty(1) == 0;
if (outRedirected) {
builder.dumb(true);
}
this.terminal = builder.build();
this.dumb = terminal.getType().startsWith("dumb");
this.noBuffering = noBuffering;
this.linesPerProject = rollingWindowSize;
Expand Down

0 comments on commit ad70393

Please sign in to comment.