Skip to content

Commit

Permalink
fix: Ignore version detection in node modules. (#282)
Browse files Browse the repository at this point in the history
  • Loading branch information
milesj authored Nov 13, 2023
1 parent f096a53 commit f6ee61e
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
- [Rust](https://github.com/moonrepo/rust-plugin/blob/master/CHANGELOG.md)
- [TOML schema](https://github.com/moonrepo/schema-plugin/blob/master/CHANGELOG.md)

## Unreleased

#### 🐞 Fixes

- Fixed an issue where version detection would read files found in `node_modules` (which you usually don't want).

## 0.22.1

#### 🐞 Fixes
Expand Down
5 changes: 3 additions & 2 deletions crates/cli/src/commands/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,9 @@ pub async fn run(args: ArgsRef<RunArgs>) -> SystemResult {

// Determine the binary path to execute
let exe_config = get_executable(&tool, args)?;
let exe_path = exe_config.exe_path.as_ref().unwrap();

debug!(bin = ?exe_config.exe_path, args = ?args.passthrough, "Running {}", tool.get_name());
debug!(bin = ?exe_path, args = ?args.passthrough, "Running {}", tool.get_name());

// Run before hook
tool.run_hook("pre_run", || RunHook {
Expand All @@ -216,7 +217,7 @@ pub async fn run(args: ArgsRef<RunArgs>) -> SystemResult {
)
.env(
format!("{}_BIN", tool.get_env_var_prefix()),
exe_config.exe_path.unwrap().to_string_lossy().to_string(),
exe_path.to_string_lossy().to_string(),
)
.spawn()
.into_diagnostic()?
Expand Down
5 changes: 5 additions & 0 deletions crates/core/src/tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,11 @@ 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")?;

Expand Down
2 changes: 1 addition & 1 deletion crates/core/src/version_detector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pub async fn detect_version(
if let Some(local_version) = config.tools.get(&tool.id) {
debug!(
tool = tool.id.as_str(),
version = ?local_version,
version = local_version.to_string(),
file = ?config.path,
"Detected version from .prototools file",
);
Expand Down
1 change: 1 addition & 0 deletions crates/pdk-api/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ json_struct!(
pub no_shim: bool,

/// The parent executable name required to execute the local executable path.
#[serde(skip_serializing_if = "Option::is_none")]
pub parent_exe_name: Option<String>,

/// Custom args to prepend to user-provided args within the generated shim.
Expand Down

0 comments on commit f6ee61e

Please sign in to comment.