Skip to content

Commit

Permalink
Update checks.
Browse files Browse the repository at this point in the history
  • Loading branch information
milesj committed Nov 13, 2023
1 parent 640eb06 commit 212eefc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#### Updates

- Added support to plugins to ignore certain paths when detecting a version.
- WASM API
- Added `DetectVersionOutput.ignore` field.

Expand Down
14 changes: 9 additions & 5 deletions crates/core/src/tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -593,6 +596,7 @@ impl Tool {
debug!(
tool = self.id.as_str(),
file = ?file_path,
version = version.to_string(),
"Detected a version"
);

Expand Down

0 comments on commit 212eefc

Please sign in to comment.