Skip to content

Commit

Permalink
chore: avoid uneeded use of jbang in plugin commands
Browse files Browse the repository at this point in the history
  • Loading branch information
iocanel committed Aug 29, 2023
1 parent 81d6c6d commit 33ec0fa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ public JBangCatalogService(boolean interactiveMode, MessageWriter output, String
this.jbang = new JBangSupport(interactiveMode, output);
}

public boolean ensureJBangIsInstalled() {
return jbang.ensureJBangIsInstalled();
}

@Override
public JBangCatalog readCatalog(Path path) {
if (!jbang.isAvailable() && !jbang.isInstallable()) {
Expand Down Expand Up @@ -93,8 +97,9 @@ public JBangCatalog readCombinedCatalog(Optional<Path> projectDir, Optional<Path
});
});

//If not catalog have been specified use all available.
if (remoteCatalogs.length == 0) {
if (!jbang.isAvailable()) {
//If jbang is not available, ignore aliases
} else if (remoteCatalogs.length == 0) { //If not catalog have been specified use all available.
aliases.putAll(listAliasesOrFallback(jbang, fallbackCatalog).entrySet()
.stream()
.filter(e -> !aliases.containsKey(e.getKey()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ public Map<String, Plugin> getInstallablePlugins() {
public Map<String, Plugin> jbangPlugins() {
boolean isUserScoped = !projectRoot.isPresent();
Map<String, Plugin> jbangPlugins = new HashMap<>();
jbangCatalogService.ensureJBangIsInstalled();
JBangCatalog jbangCatalog = jbangCatalogService.readCombinedCatalog(projectRoot, userHome);
jbangCatalog.getAliases().forEach((location, alias) -> {
String name = util.getName(location);
Expand Down

0 comments on commit 33ec0fa

Please sign in to comment.