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

devonfw / IDEasy / 18699731973

21 Oct 2025 10:41PM UTC coverage: 68.537% (+0.002%) from 68.535%
18699731973

push

github

web-flow
#1514: Fixed npm prefix not set (#1539)

Co-authored-by: Jörg Hohwiller <hohwille@users.noreply.github.com>

3469 of 5543 branches covered (62.58%)

Branch coverage included in aggregate %.

9065 of 12745 relevant lines covered (71.13%)

3.13 hits per line

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

82.35
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.version.VersionIdentifier;
10

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

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

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

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

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

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

41

42
  @Override
43
  public String getToolHelpArguments() {
44

45
    return "help";
×
46
  }
47

48
  /**
49
   * @return the {@link Path} to the npm user configuration file, creates the folder and configuration file if it was not existing.
50
   */
51
  public Path getOrCreateNpmConfigUserConfig() {
52
    Path confPath = this.context.getConfPath().resolve(NPM_HOME_FOLDER);
6✔
53
    Path npmConfigFile = confPath.resolve(".npmrc");
4✔
54
    if (!Files.isDirectory(confPath)) {
5✔
55
      this.context.getFileAccess().mkdirs(confPath);
5✔
56
      this.context.getFileAccess().touch(npmConfigFile);
5✔
57
    }
58
    return npmConfigFile;
2✔
59
  }
60
}
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