Sha256: 09d13e0339f5ec756f7041caa2244b991d6044f5839810c68f871900af6c1a75

Contents?: true

Size: 801 Bytes

Versions: 3

Compression:

Stored size: 801 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
    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 `bundler install --binstubs` from your project root to generate bundle-specific executables'
        exit!
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
padrino-core-0.13.3.1 lib/padrino-core/cli/binstub.rb
padrino-core-0.13.3 lib/padrino-core/cli/binstub.rb
padrino-core-0.12.8 lib/padrino-core/cli/binstub.rb