Skip to content

Commit

Permalink
Clarify debug message for package.json omissions
Browse files Browse the repository at this point in the history
Signed-off-by: Dan Luhring <[email protected]>
  • Loading branch information
luhring committed Jan 22, 2021
1 parent e06fb7d commit 8ecfb59
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions syft/cataloger/javascript/parse_package_json.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,8 @@ func parsePackageJSON(_ string, reader io.Reader) ([]pkg.Package, error) {
return nil, fmt.Errorf("failed to parse package.json file: %w", err)
}

if !p.hasMinimumRequiredValues() {
log.Debug("encountered package.json file without the minimum number of field values required for" +
" consideration as a package")
if !p.hasNameAndVersionValues() {
log.Debug("encountered package.json file without a name and/or version field, ignoring this file")
return nil, nil
}

Expand Down Expand Up @@ -204,6 +203,6 @@ func parsePackageJSON(_ string, reader io.Reader) ([]pkg.Package, error) {
return packages, nil
}

func (p PackageJSON) hasMinimumRequiredValues() bool {
func (p PackageJSON) hasNameAndVersionValues() bool {
return p.Name != "" && p.Version != ""
}

0 comments on commit 8ecfb59

Please sign in to comment.