File tree Expand file tree Collapse file tree 1 file changed +13
-11
lines changed Expand file tree Collapse file tree 1 file changed +13
-11
lines changed Original file line number Diff line number Diff line change @@ -42,21 +42,23 @@ module Jsbundling
42
42
end
43
43
end
44
44
45
- def tool_exists? ( tool )
46
- system "command -v #{ tool } > /dev/null"
45
+ def tool
46
+ tool_determined_by_config_file || tool_determined_by_executable
47
47
end
48
48
49
- def tool
49
+ def tool_determined_by_config_file
50
50
case
51
- when File . exist? ( "bun.lockb" ) then :bun
52
- when File . exist? ( "bun.lock" ) then :bun
53
- when File . exist? ( "yarn.lock" ) then :yarn
54
- when File . exist? ( "pnpm-lock.yaml" ) then :pnpm
51
+ when File . exist? ( "bun.lockb" ) then :bun
52
+ when File . exist? ( "bun.lock" ) then :bun
53
+ when File . exist? ( "yarn.lock" ) then :yarn
54
+ when File . exist? ( "pnpm-lock.yaml" ) then :pnpm
55
55
when File . exist? ( "package-lock.json" ) then :npm
56
- when tool_exists? ( "bun" ) then :bun
57
- when tool_exists? ( "yarn" ) then :yarn
58
- when tool_exists? ( "pnpm" ) then :pnpm
59
- when tool_exists? ( "npm" ) then :npm
56
+ end
57
+ end
58
+
59
+ def tool_determined_by_executable
60
+ %i[ bun yarn pnpm npm ] . each do |exe |
61
+ return exe if system "command -v #{ exe } > /dev/null"
60
62
end
61
63
end
62
64
end
You can’t perform that action at this time.
0 commit comments