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

devonfw / IDEasy / 21099258243

17 Jan 2026 06:52PM UTC coverage: 70.349% (-0.006%) from 70.355%
21099258243

push

github

hohwille
Merge branch 'maybeec-feature/#1667-fix-env-install-trigger'

4017 of 6298 branches covered (63.78%)

Branch coverage included in aggregate %.

10444 of 14258 relevant lines covered (73.25%)

3.17 hits per line

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

78.26
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
  @Override
43
  public String getInstalledEdition() {
44

45
    if (getInstalledVersion() != null) {
3!
46
      return this.tool;
3✔
47
    }
48
    return null;
×
49
  }
50

51
  /**
52
   * Checks if a provided binary can be found within node.
53
   *
54
   * @param binary name of the binary.
55
   * @return {@code true} if a binary was found in the node installation, {@code false} if not.
56
   */
57
  protected boolean hasNodeBinary(String binary) {
58

59
    return Files.exists(getToolBinPath().resolve(binary));
8✔
60
  }
61

62
  @Override
63
  protected String completeRequestOption(PackageManagerRequest request) {
64

65
    return switch (request.getType()) {
10!
66
      case PackageManagerRequest.TYPE_INSTALL -> "-gf";
2✔
67
      case PackageManagerRequest.TYPE_UNINSTALL -> "-g";
2✔
68
      default -> null;
×
69
    };
70
  }
71

72
  @Override
73
  public String getToolHelpArguments() {
74

75
    return "--help";
×
76
  }
77

78
  @Override
79
  public Path findBuildDescriptor(Path directory) {
80

81
    Path buildDescriptor = directory.resolve(PACKAGE_JSON);
4✔
82
    if (Files.exists(buildDescriptor)) {
5✔
83
      return buildDescriptor;
2✔
84
    }
85
    return super.findBuildDescriptor(directory);
4✔
86
  }
87
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc