From 1acc803f22c36e142112e4d956129b75006cda99 Mon Sep 17 00:00:00 2001 From: Omer Zidkoni Date: Mon, 16 Oct 2023 12:08:16 +0300 Subject: [PATCH] Yarn V1 - consider filtering `yarn list` via environment variable --- build/utils/yarn.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/build/utils/yarn.go b/build/utils/yarn.go index 1d367b75..0f1d5892 100644 --- a/build/utils/yarn.go +++ b/build/utils/yarn.go @@ -293,7 +293,9 @@ func buildYarn1Root(packageInfo *PackageInfo, packNameToFullName map[string]stri rootDeps = append(rootDeps, maps.Keys(packageInfo.OptionalDependencies)...) for _, directDepName := range rootDeps { - rootDependency.Details.Dependencies = append(rootDependency.Details.Dependencies, YarnDependencyPointer{Locator: packNameToFullName[directDepName]}) + if fullPackageName, packageExist := packNameToFullName[directDepName]; packageExist { + rootDependency.Details.Dependencies = append(rootDependency.Details.Dependencies, YarnDependencyPointer{Locator: fullPackageName}) + } } return rootDependency } @@ -357,9 +359,9 @@ func (yd *YarnDependency) Name() string { if strings.Contains(yd.Value[1:], "@") { atSignIndex := strings.Index(yd.Value[1:], "@") + 1 return yd.Value[:atSignIndex] - } else { // In some cases when using yarn V1 we encounter package names without their version (project's package name) - return yd.Value } + // In some cases when using yarn V1 we encounter package names without their version (project's package name) + return yd.Value } type YarnDepDetails struct {