generate_bundler_executable_stubs(spec, options = {})public
No documentation available.
# File lib/bundler/installer.rb, line 99
def generate_bundler_executable_stubs(spec, options = {})
if options[:binstubs_cmd] && spec.executables.empty?
options = {}
spec.runtime_dependencies.each do |dep|
bins = @definition.specs[dep].first.executables
options[dep.name] = bins unless bins.empty?
end
if options.any?
Bundler.ui.warn "#{spec.name} has no executables, but you may want " "one from a gem it depends on."
options.each {|name, bins| Bundler.ui.warn " #{name} has: #{bins.join(", ")}" }
else
Bundler.ui.warn "There are no executables for the gem #{spec.name}."
end
return
end
# double-assignment to avoid warnings about variables that will be used by ERB
bin_path = Bundler.bin_path
bin_path = bin_path
relative_gemfile_path = Bundler.default_gemfile.relative_path_from(bin_path)
relative_gemfile_path = relative_gemfile_path
ruby_command = Thor::Util.ruby_command
ruby_command = ruby_command
template_path = File.expand_path("../templates/Executable", __FILE__)
if spec.name == "bundler"
template_path += ".bundler"
spec.executables = %(bundle)
end
template = File.read(template_path)
exists = []
spec.executables.each do |executable|
binstub_path = "#{bin_path}/#{executable}"
if File.exist?(binstub_path) && !options[:force]
exists << executable
next
end
File.open(binstub_path, "w", 0o777 & ~File.umask) do |f|
if RUBY_VERSION >= "2.6"
f.puts ERB.new(template, :trim_mode => "-").result(binding)
else
f.puts ERB.new(template, nil, "-").result(binding)
end
end
end
if options[:binstubs_cmd] && exists.any?
case exists.size
when 1
Bundler.ui.warn "Skipped #{exists[0]} since it already exists."
when 2
Bundler.ui.warn "Skipped #{exists.join(" and ")} since they already exist."
else
items = exists[0...-1].empty? ? nil : exists[0...-1].join(", ")
skipped = [items, exists[-1]].compact.join(" and ")
Bundler.ui.warn "Skipped #{skipped} since they already exist."
end
Bundler.ui.warn "If you want to overwrite skipped stubs, use --force."
end
end