Sha256: 209f101a130f7d1085cb64e785e070bb1fcc9e601db47ba8e0ecf6a69acedfa3

Contents?: true

Size: 826 Bytes

Versions: 2

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

2 entries across 2 versions & 1 rubygems

Version Path
padrino-core-0.16.0.pre3 lib/padrino-core/cli/binstub.rb
padrino-core-0.16.0.pre2 lib/padrino-core/cli/binstub.rb