method
dockerfile_binfile_fixups
rails latest stable - Class:
Rails::Generators::AppBase
dockerfile_binfile_fixups()private
No documentation available.
# File railties/lib/rails/generators/app_base.rb, line 509
def dockerfile_binfile_fixups
# binfiles may have OS specific paths to ruby. Normalize them.
shebangs = Dir["bin/*"].map { |file| IO.read(file).lines.first }.join
rubies = shebangs.scan(%{#!/usr/bin/env (ruby.*)}).flatten.uniq
binfixups = (rubies - %(ruby)).map do |ruby|
"sed -i 's/#{Regexp.quote(ruby)}$/ruby/' bin/*"
end
# Windows line endings will cause scripts to fail. If any
# or found OR this generation is run on a windows platform
# and there are other binfixups required, then convert
# line endings. This avoids adding unnecessary fixups if
# none are required, but prepares for the need to do the
# fix line endings if other fixups are required.
has_cr = Dir["bin/*"].any? { |file| IO.read(file).include? "\r" }
if has_cr || (Gem.win_platform? && !binfixups.empty?)
binfixups.unshift 'sed -i "s/\r$//g" bin/*'
end
# Windows file systems may not have the concept of executable.
# In such cases, fix up during the build.
unless Dir["bin/*"].all? { |file| File.executable? file }
binfixups.unshift "chmod +x bin/*"
end
binfixups
end