@@ -22,15 +22,36 @@ module Cssbundling
22
22
extend self
23
23
24
24
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
28
32
end
29
33
30
34
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
34
55
end
35
56
36
57
def tool_exists? ( tool )
0 commit comments