Skip to content

Commit

Permalink
chore: prevent multiple calls to jbang version
Browse files Browse the repository at this point in the history
  • Loading branch information
iocanel committed Aug 29, 2023
1 parent 3dede5c commit c5706c5
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public class JBangSupport {
private Path workingDirectory;

private Optional<Boolean> installed = Optional.empty();
private Optional<String> version = Optional.empty();

public JBangSupport(boolean interactiveMode, MessageWriter output) {
this(interactiveMode, output, Paths.get(System.getProperty("user.dir")));
Expand Down Expand Up @@ -138,8 +139,12 @@ public List<String> execute(String... args) {
}

public Optional<String> version() {
return execute("version").stream().findFirst();

if (version.isPresent()) {
return version;
} else {
version = execute("version").stream().findFirst();
}
return version;
}

public boolean isAvailable() {
Expand Down

0 comments on commit c5706c5

Please sign in to comment.