Skip to content

Commit 09c7279

Browse files
committed
Simplify build tool selection for bun / yarn
Simplifying ahead of introducing NPM as a build tool.
1 parent b27be4a commit 09c7279

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

lib/tasks/cssbundling/build.rake

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,28 @@ module Cssbundling
2222
extend self
2323

2424
def install_command
25-
return "bun install" if File.exist?('bun.lockb') || (tool_exists?('bun') && !File.exist?('yarn.lock'))
26-
return "yarn install" if File.exist?('yarn.lock') || tool_exists?('yarn')
27-
raise "cssbundling-rails: No suitable tool found for installing JavaScript dependencies"
25+
case tool
26+
when :bun then "bun install"
27+
when :yarn then "yarn install"
28+
else raise "cssbundling-rails: No suitable tool found for installing JavaScript dependencies"
29+
end
2830
end
2931

3032
def build_command
31-
return "bun run build:css" if File.exist?('bun.lockb') || (tool_exists?('bun') && !File.exist?('yarn.lock'))
32-
return "yarn build:css" if File.exist?('yarn.lock') || tool_exists?('yarn')
33-
raise "cssbundling-rails: No suitable tool found for building CSS"
33+
case tool
34+
when :bun then "bun run build:css"
35+
when :yarn then "yarn build:css"
36+
else raise "cssbundling-rails: No suitable tool found for building CSS"
37+
end
38+
end
39+
40+
def tool
41+
case
42+
when File.exist?('bun.lockb') then :bun
43+
when File.exist?('yarn.lock') then :yarn
44+
when tool_exists?('bun') then :bun
45+
when tool_exists?('yarn') then :yarn
46+
end
3447
end
3548

3649
def tool_exists?(tool)

0 commit comments

Comments
 (0)