Skip package-lock.json and yarn.lock in node_modules #431 (#485)

Signed-off-by: Keith Zantow <kzantow@gmail.com>
This commit is contained in:
Keith Zantow
2021-08-20 13:50:28 -04:00
committed by GitHub
parent cba5b5723b
commit ff828fbac2
116 changed files with 23778 additions and 5 deletions
@@ -27,9 +27,15 @@ type Dependency struct {
Requires map[string]string
}
// parsePackageLock parses a package.lock and returns the discovered JavaScript packages.
func parsePackageLock(_ string, reader io.Reader) ([]pkg.Package, error) {
packages := make([]pkg.Package, 0)
// parsePackageLock parses a package-lock.json and returns the discovered JavaScript packages.
func parsePackageLock(path string, reader io.Reader) ([]pkg.Package, error) {
// in the case we find package-lock.json files in the node_modules directories, skip those
// as the whole purpose of the lock file is for the specific dependencies of the root project
if pathContainsNodeModulesDirectory(path) {
return nil, nil
}
var packages []pkg.Package
dec := json.NewDecoder(reader)
for {