Check to make sure a language is installed before registering it. Now if you do not have node installed for instance, you will not see it.

This commit is contained in:
Adam Sanderson 2011-01-01 09:16:19 -07:00
parent 29a1139877
commit 84d60ae661
2 changed files with 9 additions and 4 deletions

View File

@ -14,6 +14,11 @@ module Qwandry
builders[name] << block
end
def register_if_present name, binary=nil, &block
binary ||= name
register(name, &block) if system("which #{binary}")
end
# Sets the default configuration to launch, if no `configurations` are passed
# in, it returns their names.
def default(*configurations)

View File

@ -9,7 +9,7 @@ register :ruby do
end
# Register the default ruby gems configuration:
register :gem do
register_if_present :gem do
# Get the gem paths from the ruby load paths:
paths = ($:).grep(/gems/).map{|p| p[/.+\/gems\//]}.uniq
@ -18,7 +18,7 @@ register :gem do
end
# Register a perl configuration:
register :perl do
register_if_present :perl do
# Execute a perl script to find all of the perl load paths:
perl_paths = `perl -e 'foreach $k (@INC){print $k,"\n";}'` rescue ''
@ -30,7 +30,7 @@ register :perl do
end
# Add python repositories:
register :python do
register_if_present :python do
# Execute a python script to find all of the python load paths:
python_paths = `python -c 'import sys;print(\"\\n\".join(sys.path))'` rescue ''
@ -42,7 +42,7 @@ register :python do
end
# Add node.js repositories:
register :node do
register_if_present :node do
# Execute a node script to find all of the load paths:
node_script_path = File.join(File.dirname(__FILE__),'probe_node.js')
node_paths = `node #{node_script_path}` rescue ''