From 212eefc2d6c27111baf9dc2e720c4b09b8d102a9 Mon Sep 17 00:00:00 2001 From: Miles Johnson Date: Mon, 13 Nov 2023 15:47:32 -0800 Subject: [PATCH] Update checks. --- CHANGELOG.md | 1 + crates/core/src/tool.rs | 14 +++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b50842970..ad704ec2f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ #### Updates +- Added support to plugins to ignore certain paths when detecting a version. - WASM API - Added `DetectVersionOutput.ignore` field. diff --git a/crates/core/src/tool.rs b/crates/core/src/tool.rs index 6495493dd..a4298ffaa 100644 --- a/crates/core/src/tool.rs +++ b/crates/core/src/tool.rs @@ -546,14 +546,17 @@ impl Tool { return Ok(None); } - // TODO move this into plugins - if current_dir.to_string_lossy().contains("node_modules") { - return Ok(None); - } - let has_parser = self.plugin.has_func("parse_version_file"); let result: DetectVersionOutput = self.plugin.cache_func("detect_version_files")?; + if !result.ignore.is_empty() { + if let Some(dir) = current_dir.to_str() { + if result.ignore.iter().any(|ignore| dir.contains(ignore)) { + return Ok(None); + } + } + } + trace!( tool = self.id.as_str(), dir = ?current_dir, @@ -593,6 +596,7 @@ impl Tool { debug!( tool = self.id.as_str(), file = ?file_path, + version = version.to_string(), "Detected a version" );