Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add current dir to LOAD_PATH only when --require option is used #117

Merged
merged 2 commits into from
Apr 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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