From 06df2d446377d79a8e66391d8dc6d7aa314d5652 Mon Sep 17 00:00:00 2001 From: Vijayan T Date: Thu, 27 Jun 2024 16:06:31 +0530 Subject: [PATCH] Improving buildDescriptorExcludeList for npm (#4976) Signed-off-by: Vijayan T --- pkg/whitesource/configHelper.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pkg/whitesource/configHelper.go b/pkg/whitesource/configHelper.go index a36592ede3..c18b6d6ff6 100644 --- a/pkg/whitesource/configHelper.go +++ b/pkg/whitesource/configHelper.go @@ -266,6 +266,19 @@ func (c *ConfigOptions) addBuildToolDefaults(config *ScanOptions, utils Utils) e } } + if config.BuildTool == "npm" { + if len(config.BuildDescriptorExcludeList) > 0 { + var excludePaths []string + for _, buildDescriptor := range config.BuildDescriptorExcludeList { + if strings.HasSuffix(buildDescriptor, "pom.xml") { + continue + } + modulePath, _ := filepath.Split(buildDescriptor) + excludePaths = append(excludePaths, modulePath) + } + *c = append(*c, ConfigOption{Name: "npm.ignoreDirectoryPatterns", Value: strings.Join(excludePaths, ",")}) + } + } if config.BuildTool == "docker" { // for now only support default name of Dockerfile