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

devonfw / IDEasy / 36534428096

29 Sep 2026 07:03AM UTC coverage: 73.865% (-0.3%) from 74.13%
36534428096

push

github

web-flow
#2293: rework spyder as ide tool commandlet (#2333)

5732 of 8665 branches covered (66.15%)

Branch coverage included in aggregate %.

15101 of 19539 relevant lines covered (77.29%)

3.31 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
  @Override
69
  public Path findBuildDescriptor(Path directory) {
70

71
    Path buildDescriptor = directory.resolve(PACKAGE_JSON);
4 ✔
72
    if (Files.exists(buildDescriptor)) {
5 !
73
      return buildDescriptor;
2 ✔
74
    }
75
    return super.findBuildDescriptor(directory);
×
76
  }
77
}
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