Skip to content

Commit

Permalink
fix: correct path for deeply nested dependencies, resolves #5116
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremylong committed Dec 10, 2022
1 parent 119c472 commit 4b286c8
Showing 1 changed file with 4 additions and 3 deletions.
Expand Up @@ -347,7 +347,7 @@ private void processDependencies(JsonObject json, File baseDir, File rootFile,
String parentPackage, Engine engine) throws AnalysisException {
final boolean skipDev = getSettings().getBoolean(Settings.KEYS.ANALYZER_NODE_PACKAGE_SKIPDEV, false);
final JsonObject deps;

final File modules_root = new File(rootFile.getParentFile(), "node_modules");
final int lockJsonVersion = json.containsKey("lockfileVersion") ? json.getInt("lockfileVersion") : 1;
if (lockJsonVersion >= 2) {
deps = json.getJsonObject("packages");
Expand All @@ -370,8 +370,9 @@ private void processDependencies(JsonObject json, File baseDir, File rootFile,
} else {
base = Paths.get(baseDir.getPath(), "node_modules", name).toFile();
if (!base.isFile()) {
if ("node_modules".equals(baseDir.getParentFile().getName())) {
base = Paths.get(baseDir.getParent(), name).toFile();
final File test = new File(modules_root, name);
if (test.isDirectory()) {
base = test;
}
}
}
Expand Down

0 comments on commit 4b286c8

Please sign in to comment.