Skip to content

Commit 5e33410

Browse files
committed
fix: normalize npm prefix paths
Signed-off-by: Ruben Romero Montes <rromerom@redhat.com>
1 parent 3e365da commit 5e33410

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

src/main/java/com/redhat/exhort/providers/JavaScriptNpmProvider.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,22 @@ protected String lockFileName() {
3737
return LOCK_FILE;
3838
}
3939

40+
/**
41+
* Helper method to normalize paths for npm on Windows. npm's --prefix option has issues with
42+
* Windows backslash paths.
43+
*/
44+
private String normalizePath(Path path) {
45+
if (Operations.isWindows()) {
46+
// Convert Windows backslashes to forward slashes for npm
47+
return path.toString().replace('\\', '/');
48+
}
49+
return path.toString();
50+
}
51+
4052
@Override
4153
protected String[] updateLockFileCmd(Path manifestDir) {
4254
return new String[] {
43-
packageManager(), "i", "--package-lock-only", "--prefix", manifestDir.toString()
55+
packageManager(), "i", "--package-lock-only", "--prefix", normalizePath(manifestDir)
4456
};
4557
}
4658

@@ -55,7 +67,7 @@ protected String[] listDepsCmd(boolean includeTransitive, Path manifestDir) {
5567
"--package-lock-only",
5668
"--json",
5769
"--prefix",
58-
manifestDir.toString()
70+
normalizePath(manifestDir)
5971
};
6072
}
6173
return new String[] {

0 commit comments

Comments
 (0)