Skip to content

Commit

Permalink
fix: Supplier field
Browse files Browse the repository at this point in the history
  • Loading branch information
williamfzc committed Aug 27, 2023
1 parent 3982d36 commit f44351f
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions pnpm/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,14 @@ func (m *Pnpm) GetRootModule(path string) (*meta.Package, error) {
if pkResult["name"] != nil {
mod.Name = pkResult["name"].(string)
}
if pkResult["author"] != nil {
mod.Supplier.Name = pkResult["author"].(string)
}
if pkResult["version"] != nil {
mod.Version = pkResult["version"].(string)
}
mod.Supplier = meta.Supplier{
Type: meta.Organization,
Name: mod.Name,
}

repository := pkResult["repository"]
if repository != nil {
if rep, ok := repository.(string); ok {
Expand Down Expand Up @@ -187,7 +189,6 @@ func (m *Pnpm) buildDependencies(path string, deps []dependency) ([]meta.Package
Algorithm: "SHA256",
Value: h,
}
de.Supplier.Name = de.Name
if de.PackageDownloadLocation == "" {
de.PackageDownloadLocation = de.Name
}
Expand Down Expand Up @@ -222,7 +223,13 @@ func (m *Pnpm) buildDependencies(path string, deps []dependency) ([]meta.Package
}
}
mod.PackageDownloadLocation = strings.TrimSuffix(strings.TrimPrefix(d.Resolved, "\""), "\"")
mod.Supplier.Name = mod.Name
mod.Supplier = meta.Supplier{
Type: meta.Organization,
Name: mod.Name,
}
if mod.Name == "" {
mod.Supplier.Name = de.Name
}

mod.PackageURL = getPackageHomepage(filepath.Join(path, m.metadata.ModulePath[0], d.PkPath, m.metadata.Manifest[0]))
h := fmt.Sprintf("%x", sha256.Sum256([]byte(mod.Name)))
Expand Down

0 comments on commit f44351f

Please sign in to comment.