Skip to content
This repository has been archived by the owner on Feb 7, 2018. It is now read-only.

Commit

Permalink
Put the supplemental path before the regular path
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon Yurek committed Jan 11, 2013
1 parent c788e5a commit eac6c94
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/cocaine/command_line.rb
Expand Up @@ -12,7 +12,7 @@ def path
def path=(supplemental_path)
@supplemental_path = supplemental_path
@supplemental_environment ||= {}
@supplemental_environment['PATH'] = [ENV['PATH'], *supplemental_path].join(File::PATH_SEPARATOR)
@supplemental_environment['PATH'] = [*supplemental_path, ENV['PATH']].join(File::PATH_SEPARATOR)
end

def posix_spawn_available?
Expand Down
16 changes: 11 additions & 5 deletions spec/cocaine/command_line_spec.rb
Expand Up @@ -12,11 +12,17 @@
end

it "specifies the $PATH where the command can be found" do
Cocaine::CommandLine.path = "/path/to/command/dir"
cmd = Cocaine::CommandLine.new("ruby", "-e 'puts ENV[%{PATH}]'")
cmd.command.should == "ruby -e 'puts ENV[%{PATH}]'"
output = cmd.run
output.should match(%r{/path/to/command/dir})
saved_path = ENV['PATH']
begin
ENV['PATH'] = "/the/environment/path:/other/bin"
Cocaine::CommandLine.path = "/path/to/command/dir"
cmd = Cocaine::CommandLine.new("echo", "$PATH")
cmd.command.should == "echo $PATH"
output = cmd.run
output.should match(%r{/path/to/command/dir:/the/environment/path:/other/bin})
ensure
ENV['PATH'] = saved_path
end
end

it "specifies more than one path where the command can be found" do
Expand Down

0 comments on commit eac6c94

Please sign in to comment.