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

devonfw / IDEasy / 18597745141

17 Oct 2025 03:44PM UTC coverage: 68.505% (+0.07%) from 68.437%
18597745141

Pull #1467

github

web-flow
Merge 7d63a50a9 into 46d29352c
Pull Request #1467: #907 Add yarn and corepack

3466 of 5539 branches covered (62.57%)

Branch coverage included in aggregate %.

9052 of 12734 relevant lines covered (71.09%)

3.13 hits per line

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

82.61
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 VersionIdentifier computeInstalledVersion() {
31
    if (hasNodeBinary("npm")) {
4!
32
      return VersionIdentifier.of(this.context.newProcess().runAndGetSingleOutput("npm", "--version"));
×
33
    }
34
    return null;
2✔
35
  }
36

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

46
  @Override
47
  public String getToolHelpArguments() {
48

49
    return "help";
×
50
  }
51

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