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

devonfw / IDEasy / 18699372415

21 Oct 2025 10:22PM UTC coverage: 68.541% (+0.02%) from 68.522%
18699372415

push

github

web-flow
#1536: Disable uninstall for corepack and npm (#1541)

3469 of 5543 branches covered (62.58%)

Branch coverage included in aggregate %.

9063 of 12741 relevant lines covered (71.13%)

3.13 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/npm/Npm.java
1
package com.devonfw.tools.ide.tool.npm;
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.process.ProcessResult;
10
import com.devonfw.tools.ide.version.VersionIdentifier;
11

12
/**
13
 * {@link NpmBasedCommandlet} for <a href="https://www.npmjs.com/">npm</a>.
14
 */
15
public class Npm extends NpmBasedCommandlet {
16

17
  private static final String NPM_HOME_FOLDER = "npm";
18

19
  /**
20
   * The constructor.
21
   *
22
   * @param context the {@link IdeContext}.
23
   */
24
  public Npm(IdeContext context) {
25

26
    super(context, "npm", Set.of(Tag.JAVA_SCRIPT, Tag.BUILD));
7✔
27
  }
1✔
28

29
  @Override
30
  protected boolean canBeUninstalled() {
31
    return false;
2✔
32
  }
33

34
  @Override
35
  protected VersionIdentifier computeInstalledVersion() {
36
    if (hasNodeBinary("npm")) {
4!
37
      return VersionIdentifier.of(this.context.newProcess().runAndGetSingleOutput("npm", "--version"));
×
38
    }
39
    return null;
2✔
40
  }
41

42
  @Override
43
  protected void postInstall() {
44
    super.postInstall();
2✔
45
    ProcessResult result = runPackageManager("config", "set", "prefix", getToolPath().toString());
23✔
46
    if (result.isSuccessful()) {
3!
47
      this.context.success("Setting npm config prefix to: {} was successful", getToolPath());
11✔
48
    }
49
  }
1✔
50

51
  @Override
52
  public String getToolHelpArguments() {
53

54
    return "help";
×
55
  }
56

57
  /**
58
   * @return the {@link Path} to the npm user configuration file, creates the folder and configuration file if it was not existing.
59
   */
60
  public Path getOrCreateNpmConfigUserConfig() {
61
    Path confPath = this.context.getConfPath().resolve(NPM_HOME_FOLDER);
6✔
62
    Path npmConfigFile = confPath.resolve(".npmrc");
4✔
63
    if (!Files.isDirectory(confPath)) {
5✔
64
      this.context.getFileAccess().mkdirs(confPath);
5✔
65
      this.context.getFileAccess().touch(npmConfigFile);
5✔
66
    }
67
    return npmConfigFile;
2✔
68
  }
69
}
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