From 4d30890089fd8849e917615ddcafbc68e7743995 Mon Sep 17 00:00:00 2001 From: Jacob Barrieault Date: Thu, 6 Mar 2025 17:22:26 -0500 Subject: [PATCH 1/3] Detect Bun tool when using bun.lock and yarn.lock --- lib/tasks/jsbundling/build.rake | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/tasks/jsbundling/build.rake b/lib/tasks/jsbundling/build.rake index c6b29aa..684bf33 100644 --- a/lib/tasks/jsbundling/build.rake +++ b/lib/tasks/jsbundling/build.rake @@ -49,6 +49,7 @@ module Jsbundling def tool case 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 From 567144fb5dac7664a3a0271862eb9b4bcd79b443 Mon Sep 17 00:00:00 2001 From: Jacob Barrieault Date: Sat, 8 Mar 2025 10:57:25 -0500 Subject: [PATCH 2/3] use double-quote string linterals to be consistent with the rest of the file/project --- lib/tasks/jsbundling/build.rake | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/tasks/jsbundling/build.rake b/lib/tasks/jsbundling/build.rake index 684bf33..a8005e6 100644 --- a/lib/tasks/jsbundling/build.rake +++ b/lib/tasks/jsbundling/build.rake @@ -48,15 +48,15 @@ module Jsbundling def tool case - 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 - 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 + when tool_exists?("bun") then :bun + when tool_exists?("yarn") then :yarn + when tool_exists?("pnpm") then :pnpm + when tool_exists?("npm") then :npm end end end From 022789a363398351807d9105420777a948b51b85 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sun, 9 Mar 2025 14:16:25 +0100 Subject: [PATCH 3/3] Improve tool selection --- lib/tasks/jsbundling/build.rake | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/lib/tasks/jsbundling/build.rake b/lib/tasks/jsbundling/build.rake index a8005e6..62ee0aa 100644 --- a/lib/tasks/jsbundling/build.rake +++ b/lib/tasks/jsbundling/build.rake @@ -42,21 +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?("bun.lock") then :bun - when File.exist?("yarn.lock") then :yarn - when File.exist?("pnpm-lock.yaml") then :pnpm + 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 - when tool_exists?("bun") then :bun - when tool_exists?("yarn") then :yarn - when tool_exists?("pnpm") then :pnpm - when tool_exists?("npm") 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