From 24d7ee9fb5393f00ac240639e7eeec734f7d1135 Mon Sep 17 00:00:00 2001 From: Nikolay Markov Date: Tue, 2 Apr 2019 14:56:41 +0300 Subject: [PATCH 1/2] Add current dir to LOAD_PATH only when --require option is used --- exe/racecar | 2 -- lib/racecar/cli.rb | 4 ++++ 2 files changed, 4 insertions(+), 2 deletions(-) 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 From eedb6baff577f740048d222bbbb7ab0532deac88 Mon Sep 17 00:00:00 2001 From: Nikolay Markov Date: Tue, 2 Apr 2019 15:00:25 +0300 Subject: [PATCH 2/2] Add note to changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) 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).