Sha256: ce24d9c82520b0e1de061c9ddd4998d2071bc04c2992bdefbb433ba0f882bc05

Contents?: true

Size: 826 Bytes

Versions: 4

Compression:

Stored size: 826 Bytes

Contents

module Padrino
  ##
  # Replaces the current process with it's binstub.
  #
  def self.replace_with_binstub(executable)
    begin
      return if Bundler.definition.missing_specs.empty?
    rescue NameError, NoMethodError, Bundler::GemfileNotFound
    end

    project_root = Dir.pwd
    until project_root.empty?
      break if File.file?(File.join(project_root, 'Gemfile'))
      project_root = project_root.rpartition('/').first
    end

    if %w(Gemfile .components).all? { |file| File.file?(File.join(project_root, file)) }
      binstub = File.join(project_root, 'bin', executable)
      if File.file?(binstub)
        exec Gem.ruby, binstub, *ARGV
      else
        puts 'Please run `bundle install --binstubs` from your project root to generate bundle-specific executables'
        exit!
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
padrino-core-0.15.3 lib/padrino-core/cli/binstub.rb
padrino-core-0.15.2 lib/padrino-core/cli/binstub.rb
padrino-core-0.15.1 lib/padrino-core/cli/binstub.rb
padrino-core-0.15.0 lib/padrino-core/cli/binstub.rb