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

Enable running rake through zeus if it is present and running #30

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 20 additions & 1 deletion lib/hookup.rb
@@ -1,3 +1,5 @@
require 'stringio'

class Hookup

class Error < RuntimeError
Expand Down Expand Up @@ -144,6 +146,21 @@ def bundler?
File.exist?('Gemfile')
end

def zeus?
File.exist?('.zeus.sock') && zeus_running?
end

def zeus_running?
processes = StringIO.new(%x{ps | grep 'zeus'}).readlines
!!processes.detect do |e|
# greedily read up to last digit, so that this:
# 14105 ttys000 0:01.66 zeus slave: boot
# becomes this:
# zeus slave: boot
e.split(/.+\d/).last.strip == 'zeus slave: boot'
end
end

def bundle
return unless bundler?
if %x{git diff --name-only #{old} #{new}} =~ /^Gemfile|\.gemspec$/
Expand Down Expand Up @@ -212,7 +229,9 @@ def migrate

def rake(*args)
Dir.chdir(working_dir) do
if bundler?
if zeus?
system 'zeus', 'rake', *args
elsif bundler?
system 'bundle', 'exec', 'rake', *args
else
system 'rake', *args
Expand Down