/
setup.task
34 lines (26 loc) · 1.15 KB
/
setup.task
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
sym_prefix = ENV["PREFIX"] || ".."
def git_clone(type)
if File.exist? subproject.name then $stderr.puts "#{subproject.name} already exists"
else sh "git clone #{subproject.send type} #{subproject.name}"
end
end
task :gitignore do
files = File.read(".gitignore").split "\n"
files += Subproject.names
File.open(".gitignore", "w") { |f| f.puts files.uniq.sort.join("\n") }
end
project_namespace :setup do
desc "sets up %s as symlink (from #{File.expand_path sym_prefix}, change by setting PATH)"
project_task :symlink => :gitignore do
target = File.join sym_prefix, subproject.name
if File.exist? subproject.name then $stderr.puts "#{subproject.name} already exists"
elsif not File.exist? target then $stderr.puts "#{target} does not exist"
else ln_sf target, subproject.name
end
end
desc "clone read-write version of %s github repo"
project_task(:read_write => :gitignore) { git_clone :private_remote }
desc "clone read-only version of %s github repo"
project_task(:read_only => :gitignore) { git_clone :public_remote }
project_task(:check) { raise "#{subproject.name} is missing" unless File.exist? subproject.name }
end