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

devonfw / IDEasy / 18947576211

30 Oct 2025 04:19PM UTC coverage: 68.88% (+0.005%) from 68.875%
18947576211

push

github

web-flow
#1555: Add npm_config_prefix env variable to Npm (#1556)

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

3485 of 5543 branches covered (62.87%)

Branch coverage included in aggregate %.

9120 of 12757 relevant lines covered (71.49%)

3.14 hits per line

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

85.0
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.EnvironmentContext;
10
import com.devonfw.tools.ide.tool.ToolInstallation;
11
import com.devonfw.tools.ide.version.VersionIdentifier;
12

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

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

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

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

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

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

43

44
  @Override
45
  public String getToolHelpArguments() {
46

47
    return "help";
×
48
  }
49

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

63
  @Override
64
  public void setEnvironment(EnvironmentContext environmentContext, ToolInstallation toolInstallation, boolean extraInstallation) {
65
    super.setEnvironment(environmentContext, toolInstallation, extraInstallation);
5✔
66
    environmentContext.withEnvVar("npm_config_prefix", this.context.getSoftwarePath().resolve("node").toString());
10✔
67
  }
1✔
68
}
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