lib/generators/dockerfile_generator.rb in dockerfile-rails-1.0.7 vs lib/generators/dockerfile_generator.rb in dockerfile-rails-1.0.8

- old
+ new

@@ -386,21 +386,21 @@ 'sqlite3' end end def node_version + version = nil + if File.exist? '.node-version' - IO.read('.node-version')[/\d+\.\d+\.\d+/] - else - version = nil + version = IO.read('.node-version')[/\d+\.\d+\.\d+/] + end - if File.exist? 'package.json' - version = JSON.parse(IO.read('package.json')).dig("engines", "node") - version = nil unless version =~ /\A(\d+\.)+(\d+|x)\z/ - end - - version || `node --version`[/\d+\.\d+\.\d+/] + if !version and File.exist? 'package.json' + version = JSON.parse(IO.read('package.json')).dig("engines", "node") + version = nil unless version =~ /\A(\d+\.)+(\d+|x)\z/ end + + version || `node --version`[/\d+\.\d+\.\d+/] rescue "lts" end def yarn_version