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

devonfw / IDEasy / 39247962780

19 Oct 2026 11:53AM UTC coverage: 74.847% (+0.2%) from 74.686%
39247962780

Pull #2586

github

web-flow
Merge b98ec53dc into 553131e8b
Pull Request #2586: #2585: Create npm base commandlet for gemini cli

5871 of 8723 branches covered (67.3%)

Branch coverage included in aggregate %.

15366 of 19651 relevant lines covered (78.19%)

3.36 hits per line

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

66.67
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.AbstractToolCommandlet;
10
import com.devonfw.tools.ide.tool.PackageManagerBasedLocalToolCommandlet;
11
import com.devonfw.tools.ide.tool.PackageManagerRequest;
12

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

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

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

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

35
  @Override
36
  protected Node getParentTool() {
37

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

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

49
    return Files.exists(getToolBinPath().resolve(binary));
×
50
  }
51

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

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

62
  @Override
63
  public String getToolHelpArguments() {
64

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

68
  /**
69
   * @param directory the {@link Path} to the build directory.
70
   * @return the build descriptor file ({@value #PACKAGE_JSON}) or {@code null} if not found.
71
   */
72
  public Path findBuildDescriptor(Path directory) {
73

74
    Path buildDescriptor = directory.resolve(PACKAGE_JSON);
4 ✔
75
    if (Files.exists(buildDescriptor)) {
5 !
76
      return buildDescriptor;
2 ✔
77
    }
78
    return null;
×
79
  }
80
}
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