Skip to content

Commit

Permalink
Merge branch 'master' into gopkg-vcsurl
Browse files Browse the repository at this point in the history
  • Loading branch information
CaMoPeZzz committed Dec 24, 2024
2 parents da784a7 + 59e97b7 commit 47be52e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
28 changes: 26 additions & 2 deletions lib/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2537,9 +2537,33 @@ export async function createNodejsBom(path, options) {
// Parse package-lock.json if available
const parsedList = await parsePkgLock(f, options);
const dlist = parsedList.pkgList;
const tmpParentComponent = dlist.splice(0, 1)[0] || {};
tmpParentComponent.type = "application";
let tmpParentComponent = dlist.splice(0, 1)[0] || {};
if (!Object.keys(parentComponent).length) {
const basePath = dirname(f);
const packageJsonF = join(basePath, "package.json");
if (existsSync(packageJsonF)) {
const pcs = await parsePkgJson(packageJsonF, true);
if (pcs.length) {
tmpParentComponent = pcs[0];
tmpParentComponent.type = "application";
tmpParentComponent.name =
"project-name" in options
? options.projectName
: tmpParentComponent.name;
ppurl = new PackageURL(
"npm",
options.projectGroup || tmpParentComponent.group,
"project-name" in options
? options.projectName
: tmpParentComponent.name,
options.projectVersion || tmpParentComponent.version,
null,
null,
).toString();
tmpParentComponent["bom-ref"] = decodeURIComponent(ppurl);
tmpParentComponent["purl"] = ppurl;
}
}
parentComponent = tmpParentComponent;
} else {
parentSubComponents.push(tmpParentComponent);
Expand Down
2 changes: 1 addition & 1 deletion types/lib/cli/index.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 47be52e

Please sign in to comment.