Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect Bun tool when using bun.lock and yarn.lock #213

Merged
merged 3 commits into from
Mar 9, 2025
Merged
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
25 changes: 14 additions & 11 deletions lib/tasks/jsbundling/build.rake
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,23 @@ module Jsbundling
end
end

def tool_exists?(tool)
system "command -v #{tool} > /dev/null"
def tool
tool_determined_by_config_file || tool_determined_by_executable
end

def tool
def tool_determined_by_config_file
case
when File.exist?('bun.lockb') then :bun
when File.exist?('yarn.lock') then :yarn
when File.exist?('pnpm-lock.yaml') then :pnpm
when File.exist?('package-lock.json') then :npm
when tool_exists?('bun') then :bun
when tool_exists?('yarn') then :yarn
when tool_exists?('pnpm') then :pnpm
when tool_exists?('npm') then :npm
when File.exist?("bun.lockb") then :bun
when File.exist?("bun.lock") then :bun
when File.exist?("yarn.lock") then :yarn
when File.exist?("pnpm-lock.yaml") then :pnpm
when File.exist?("package-lock.json") then :npm
end
end

def tool_determined_by_executable
%i[ bun yarn pnpm npm ].each do |exe|
return exe if system "command -v #{exe} > /dev/null"
end
end
end
Expand Down