diff --git a/CHANGELOG.md b/CHANGELOG.md index f2dbe9d9..1560ff9f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Unreleased +* Add current directory to `$LOAD_PATH` only when `--require` option is used (#117). + ## racecar v0.5.0 * Add support for manually sending heartbeats with `heartbeat` (#105). diff --git a/exe/racecar b/exe/racecar index 30196514..7e0fc0f1 100755 --- a/exe/racecar +++ b/exe/racecar @@ -3,8 +3,6 @@ require "racecar" require "racecar/cli" -$LOAD_PATH.unshift(Dir.pwd) - begin Racecar::Cli.main(ARGV) rescue SignalException => e diff --git a/lib/racecar/cli.rb b/lib/racecar/cli.rb index e7ca2df2..bbeed404 100644 --- a/lib/racecar/cli.rb +++ b/lib/racecar/cli.rb @@ -94,10 +94,14 @@ def daemonize! end def build_parser + load_path_modified = false + OptionParser.new do |opts| opts.banner = "Usage: racecar MyConsumer [options]" opts.on("-r", "--require STRING", "Require a library before starting the consumer") do |lib| + $LOAD_PATH.unshift(Dir.pwd) unless load_path_modified + load_path_modified = true require lib end