• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

devonfw / IDEasy / 31581158018

12 Aug 2026 09:03AM UTC coverage: 72.945% (+0.05%) from 72.899%
31581158018

Pull #2306

github

web-flow
Merge 26c838aae into e226b62d2
Pull Request #2306: #2296: Refactor ToolCommandlet to determine InstalledEdition and Version in a Single Cached Lookup

5123 of 7773 branches covered (65.91%)

Branch coverage included in aggregate %.

13365 of 17572 relevant lines covered (76.06%)

3.23 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

83.33
cli/src/main/java/com/devonfw/tools/ide/tool/node/NodeBasedCommandlet.java
1
package com.devonfw.tools.ide.tool.node;
2

3
import java.nio.file.Files;
4
import java.nio.file.Path;
5
import java.util.Set;
6

7
import com.devonfw.tools.ide.common.Tag;
8
import com.devonfw.tools.ide.context.IdeContext;
9
import com.devonfw.tools.ide.tool.LocalToolCommandlet;
10
import com.devonfw.tools.ide.tool.PackageManagerBasedLocalToolCommandlet;
11
import com.devonfw.tools.ide.tool.PackageManagerRequest;
12
import com.devonfw.tools.ide.tool.ToolCommandlet;
13

14
/**
15
 * {@link LocalToolCommandlet} for tools based on <a href="https://www.npmjs.com/">npm</a>.
16
 *
17
 * @param <P> type of the {@link ToolCommandlet} acting as {@link #getPackageManagerClass() package manager}.
18
 */
19
public abstract class NodeBasedCommandlet<P extends ToolCommandlet> extends PackageManagerBasedLocalToolCommandlet<P> {
20

21
  /** File name of the {@link #findBuildDescriptor(Path) build descriptor} . */
22
  public static final String PACKAGE_JSON = "package.json";
23

24
  /**
25
   * The constructor.
26
   *
27
   * @param context the {@link IdeContext}.
28
   * @param tool the {@link #getName() tool name}.
29
   * @param tags the {@link #getTags() tags} classifying the tool. Should be created via {@link Set#of(Object) Set.of} method.
30
   */
31
  public NodeBasedCommandlet(IdeContext context, String tool, Set<Tag> tags) {
32

33
    super(context, tool, tags);
5✔
34
  }
1✔
35

36
  @Override
37
  protected Node getParentTool() {
38

39
    return this.context.getCommandletManager().getCommandlet(Node.class);
7✔
40
  }
41

42
  /**
43
   * Checks if a provided binary can be found within node.
44
   *
45
   * @param binary name of the binary.
46
   * @return {@code true} if a binary was found in the node installation, {@code false} if not.
47
   */
48
  protected boolean hasNodeBinary(String binary) {
49

50
    return Files.exists(getToolBinPath().resolve(binary));
8✔
51
  }
52

53
  @Override
54
  protected String completeRequestOption(PackageManagerRequest request) {
55

56
    return switch (request.getType()) {
10!
57
      case PackageManagerRequest.TYPE_INSTALL -> "-gf";
2✔
58
      case PackageManagerRequest.TYPE_UNINSTALL -> "-g";
2✔
59
      default -> null;
×
60
    };
61
  }
62

63
  @Override
64
  public String getToolHelpArguments() {
65

66
    return "--help";
×
67
  }
68

69
  @Override
70
  public Path findBuildDescriptor(Path directory) {
71

72
    Path buildDescriptor = directory.resolve(PACKAGE_JSON);
4✔
73
    if (Files.exists(buildDescriptor)) {
5✔
74
      return buildDescriptor;
2✔
75
    }
76
    return super.findBuildDescriptor(directory);
4✔
77
  }
78
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc