Skip to content

Commit

Permalink
Sniff around for Gemfiles
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonrclark committed Aug 2, 2017
1 parent 8ed4455 commit 034337d
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion shoes-swt/bin/shoes-swt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,31 @@
lib_directory = File.expand_path('../../lib', __FILE__)
$LOAD_PATH << lib_directory

if File.exist?("Gemfile")
# We want the Gemfile alongside the Shoes code that we're executing, not
# necessarily the Gemfile in our current directory. This helps in both running
# and packaging apps that have their own Gemfiles, even if we run `shoes` from
# another location.
candidates = (ARGV + ["."]).map do |candidate|
File.join(File.dirname(candidate), "Gemfile")
end

gemfile = candidates.uniq.find do |candidate|
File.exist?(candidate)
end

if gemfile
if defined?(Bundler) && gemfile != Bundler.default_gemfile
puts <<~EOS
Shoes wants to load the Gemfile from '#{gemfile}'
But you've already loaded Gemfile at '#{Bundler.default_gemfile}'
Instead of `bundle exec shoes`, try just `shoes` instead. We'll load Bundler for you.
EOS
end

# Thanks Bundler for the ENV vars! <3
ENV["BUNDLE_GEMFILE"] = gemfile
require "bundler/setup"
Bundler.require
end
Expand Down

0 comments on commit 034337d

Please sign in to comment.