method

dockerfile_binfile_fixups

Importance_0
v8.1.1 - Show latest stable - 0 notes - Class: AppBase
dockerfile_binfile_fixups() private

No documentation

This method has no description. You can help the Ruby on Rails community by adding new notes.

Hide source
# File railties/lib/rails/generators/app_base.rb, line 570
      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
Register or log in to add new notes.