Skip to content

Commit

Permalink
Fix bug related to dep in a rubygem context.
Browse files Browse the repository at this point in the history
So the release of 1.0.5 was supposed to make dep work as
a single script, mainly to simplify our workflow.

That introduced a couple of bugs related to rubygems
wrapping the script as a bin script.
  • Loading branch information
cyx committed Mar 22, 2013
1 parent 62e53f6 commit 4c9a472
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions bin/dep
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,10 @@ private
end
end

if __FILE__ == $0
# So originally, this was just $0 == __FILE__, but
# since rubygems wraps the actual bin file in a loader
# script, we have to instead rely on a different condition.
if File.basename($0) == "dep"

Dep::CLI.file = File.join(Dir.pwd, ".gems")
Dep::CLI.prerelease = false
Expand All @@ -160,7 +163,11 @@ if __FILE__ == $0
end

on("--help") do
IO.popen("less", "w") { |f| f.write(DATA.read) }
# I hate this, but since rubygems does a wrapper
# script, we can't use the elegance of DATA.read :(
help = File.read(__FILE__).split(/^__END__/)[1]

IO.popen("less", "w") { |f| f.write(help) }
exit
end

Expand All @@ -184,7 +191,6 @@ if __FILE__ == $0
end

__END__

DEP(1)

NAME
Expand Down

0 comments on commit 4c9a472

Please sign in to comment.