Skip to content

Commit e650c9a

Browse files
authored
PNPM Support (#145)
* Simplify build tool selection for bun / yarn Simplifying ahead of introducing NPM as a build tool. * Support for NPM * Support PNPM
1 parent 3e768cd commit e650c9a

File tree

1 file changed

+27
-6
lines changed

1 file changed

+27
-6
lines changed

lib/tasks/cssbundling/build.rake

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,36 @@ 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+
when :pnpm then "pnpm install"
29+
when :npm then "npm install"
30+
else raise "cssbundling-rails: No suitable tool found for installing JavaScript dependencies"
31+
end
2832
end
2933

3034
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"
35+
case tool
36+
when :bun then "bun run build:css"
37+
when :yarn then "yarn build:css"
38+
when :pnpm then "pnpm build:css"
39+
when :npm then "npm run build:css"
40+
else raise "cssbundling-rails: No suitable tool found for building CSS"
41+
end
42+
end
43+
44+
def tool
45+
case
46+
when File.exist?('bun.lockb') then :bun
47+
when File.exist?('yarn.lock') then :yarn
48+
when File.exist?('pnpm-lock.yaml') then :pnpm
49+
when File.exist?('package-lock.json') then :npm
50+
when tool_exists?('bun') then :bun
51+
when tool_exists?('yarn') then :yarn
52+
when tool_exists?('pnpm') then :pnpm
53+
when tool_exists?('npm') then :npm
54+
end
3455
end
3556

3657
def tool_exists?(tool)

0 commit comments

Comments
 (0)