File tree Expand file tree Collapse file tree 1 file changed +9
-17
lines changed
railties/lib/rails/generators Expand file tree Collapse file tree 1 file changed +9
-17
lines changed Original file line number Diff line number Diff line change @@ -529,38 +529,30 @@ def using_bun?
529
529
using_js_runtime? && %w[ bun ] . include? ( options [ :javascript ] )
530
530
end
531
531
532
+ def capture_command ( command , pattern )
533
+ `#{ command } ` [ pattern ]
534
+ rescue SystemCallError
535
+ nil
536
+ end
537
+
532
538
def node_version
533
539
if using_node?
534
540
ENV . fetch ( "NODE_VERSION" ) do
535
- `node --version` [ /\d +\. \d +\. \d +/ ]
536
- rescue
537
- NODE_LTS_VERSION
541
+ capture_command ( "node --version" , /\d +\. \d +\. \d +/ ) || NODE_LTS_VERSION
538
542
end
539
543
end
540
544
end
541
545
542
546
def dockerfile_yarn_version
543
- version = begin
544
- `yarn --version` [ /\d +\. \d +\. \d +/ ]
545
- rescue
546
- nil
547
- end
548
-
549
- version || "latest"
547
+ capture_command ( "yarn --version" , /\d +\. \d +\. \d +/ ) || "latest"
550
548
end
551
549
552
550
def yarn_through_corepack?
553
551
using_node? and "#{ dockerfile_yarn_version } " >= "2"
554
552
end
555
553
556
554
def dockerfile_bun_version
557
- version = begin
558
- `bun --version` [ /\d +\. \d +\. \d +/ ]
559
- rescue
560
- nil
561
- end
562
-
563
- version || BUN_VERSION
555
+ capture_command ( "bun --version" , /\d +\. \d +\. \d +/ ) || BUN_VERSION
564
556
end
565
557
566
558
def dockerfile_binfile_fixups
You can’t perform that action at this time.
0 commit comments