diff --git a/bin/tf b/bin/tf index b82873a..abd2fcf 100755 --- a/bin/tf +++ b/bin/tf @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -require 'bundler/setup' if File.exist? File.expand_path('../../Gemfile', __FILE__) +require 'bundler/setup' if File.exist?(File.expand_path('../../Gemfile', __FILE__)) require 'yle_tf/cli' cli = YleTf::CLI.new(ARGV) diff --git a/lib/yle_tf/plugin/loader.rb b/lib/yle_tf/plugin/loader.rb index c7823aa..cdbede8 100644 --- a/lib/yle_tf/plugin/loader.rb +++ b/lib/yle_tf/plugin/loader.rb @@ -19,10 +19,10 @@ def self.load_core_plugins end def self.load_bundler_plugins - if defined?(Bundler) - print_bundler_plugin_list if Logger.debug? - Bundler.require(BUNDLER_PLUGIN_GROUP) - end + return if !bundler_set_up? + + Logger.debug { print_bundler_plugin_list } + Bundler.require(BUNDLER_PLUGIN_GROUP) end def self.load_user_plugins @@ -47,6 +47,10 @@ def self.user_plugins ENV.fetch('TF_PLUGINS', '').split(/[ ,]+/) end + def self.bundler_set_up? + defined?(Bundler) && Bundler.respond_to?(:require) + end + def self.print_bundler_plugin_list plugins = bundler_plugins if !plugins.empty?