Skip to content

Commit

Permalink
Merge pull request #117 from mainameiz/modify-load-path-only-if-requi…
Browse files Browse the repository at this point in the history
…re-option-is-used

Add current dir to LOAD_PATH only when --require option is used
  • Loading branch information
dasch committed Apr 2, 2019
2 parents 0653d6c + eedb6ba commit a6201ef
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
2 changes: 0 additions & 2 deletions exe/racecar
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
require "racecar"
require "racecar/cli"

$LOAD_PATH.unshift(Dir.pwd)

begin
Racecar::Cli.main(ARGV)
rescue SignalException => e
Expand Down
4 changes: 4 additions & 0 deletions lib/racecar/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit a6201ef

Please sign in to comment.