Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,7 @@ fn main() {
};

// Search for runners
let search_result = search_runners(
&current_dir,
max_levels,
&ignore_list,
verbose,
);
let search_result = search_runners(&current_dir, max_levels, &ignore_list, verbose);

// Prepare to inject custom commands
// Filter empty commands
Expand All @@ -115,7 +110,7 @@ fn main() {

let has_valid_commands = valid_config_commands
.as_ref()
.map_or(false, |c| !c.is_empty());
.is_some_and(|c| !c.is_empty());

let (mut runners, working_dir) = match search_result {
Ok(result) => result,
Expand All @@ -135,7 +130,10 @@ fn main() {
if let Some(valid_config_commands) = valid_config_commands {
if !valid_config_commands.is_empty() {
// Check if we already have a custom runner
if let Some(idx) = runners.iter().position(|r| r.ecosystem == Ecosystem::Custom) {
if let Some(idx) = runners
.iter()
.position(|r| r.ecosystem == Ecosystem::Custom)
{
// Merge config commands into existing runner (local overrides global)
let mut merged_commands = valid_config_commands.clone();
if let Some(existing_cmds) = &runners[idx].custom_commands {
Expand Down
51 changes: 31 additions & 20 deletions src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,27 +90,25 @@ pub fn check_conflicts(

// Check for conflicts within ecosystems
for (ecosystem, eco_runners) in &by_ecosystem {
if eco_runners.len() > 1 {
if eco_runners.len() > 1 && *ecosystem == Ecosystem::NodeJs {
// For Node.js ecosystem, try to use Corepack to resolve
if *ecosystem == Ecosystem::NodeJs {
if let Some(corepack_pm) = node::get_corepack_manager(working_dir) {
// Find the runner that matches the Corepack package manager
if let Some(runner) = eco_runners.iter().find(|r| r.name == corepack_pm) {
if verbose {
output::info(&format!(
"Using {} (specified by packageManager in package.json)",
corepack_pm
));
}
return Ok((*runner).clone());
} else {
// Corepack specifies a PM but we don't have a matching lockfile
if verbose {
output::warning(&format!(
"packageManager specifies '{}' but no matching lockfile found",
corepack_pm
));
}
if let Some(corepack_pm) = node::get_corepack_manager(working_dir) {
// Find the runner that matches the Corepack package manager
if let Some(runner) = eco_runners.iter().find(|r| r.name == corepack_pm) {
if verbose {
output::info(&format!(
"Using {} (specified by packageManager in package.json)",
corepack_pm
));
}
return Ok((*runner).clone());
} else {
// Corepack specifies a PM but we don't have a matching lockfile
if verbose {
output::warning(&format!(
"packageManager specifies '{}' but no matching lockfile found",
corepack_pm
));
}
}
}
Expand Down Expand Up @@ -378,4 +376,17 @@ mod tests {
let result = check_conflicts(&runners, dir.path(), false).unwrap();
assert_eq!(result.name, "pnpm");
}

#[test]
fn test_check_conflicts_non_nodejs_ecosystem() {
let dir = tempdir().unwrap();
let runners = vec![
DetectedRunner::new("bundler", "Gemfile.lock", Ecosystem::Ruby, 13),
DetectedRunner::new("rake", "Rakefile", Ecosystem::Ruby, 14),
];

// Should not throw a LockfileConflict for non-NodeJs ecosystems
let result = check_conflicts(&runners, dir.path(), false).unwrap();
assert_eq!(result.name, "bundler"); // Higher priority wins
}
}
Loading