Skip to content

Commit

Permalink
fix use of foreign internals
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com>
  • Loading branch information
jkowalleck committed May 5, 2022
1 parent 5f7e967 commit 67bf6cd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 2 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ All notable changes to this project will be documented in this file.

* Misc
* Removed dev-files from release package, like `tests`. (via [#54])
* Fixed use of internals from foreign packages. (via [#60])

[#54]: https://github.com/CycloneDX/cyclonedx-webpack-plugin/pull/54
[#60]: https://github.com/CycloneDX/cyclonedx-webpack-plugin/pull/60

## 2.0.0 - 2022-04-24

Expand Down
14 changes: 7 additions & 7 deletions src/webpack-plugin/bomGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,22 +98,22 @@ const resolveComponents = async function (modules = [], defaultModule = {}) {
// Add the dependency relationships
// requester -depends on-> dependency
// dependency -is required by-> requester
if (dd && dr && dd._ref !== dr._ref) {
if (dd && dr && dd.ref !== dr.ref) {
let b = false
for (const d of dr._dependencies) {
if (d._ref === dd._ref) b = true
for (const d of dr.dependencies) {
if (d.ref === dd.ref) b = true
}
if (!b) { // prevent duplicates
dr._dependencies.push(dd)
dr.dependencies.push(dd)
}
}

// Determine 'root' module by identifying dependencies that are not required
// by a requester or which do not have a 'node_modules' directory
if (dd) {
if (!requiredByLookup[dd._ref]) requiredByLookup[dd._ref] = 0
if ((dr && dd._ref !== dr._ref) || dependencyPath.includes('node_modules')) {
requiredByLookup[dd._ref]++
if (!requiredByLookup[dd.ref]) requiredByLookup[dd.ref] = 0
if ((dr && dd.ref !== dr.ref) || dependencyPath.includes('node_modules')) {
++requiredByLookup[dd.ref]
}
}

Expand Down

0 comments on commit 67bf6cd

Please sign in to comment.