-
-
Save levicook/304090 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require "pathname" | |
LOADER = ''' | |
require "pathname" | |
vendor_path = Pathname.new(__FILE__).parent.parent + "vendor" | |
Pathname.glob("#{vendor_path}/**/**/lib") do |lib| | |
next if $LOAD_PATH.include?(lib.realpath.to_s) | |
$LOAD_PATH.insert(0, lib.realpath.to_s) if lib.directory? | |
end | |
''' | |
if ARGV[0] == "init" | |
lib = Pathname.new(ARGV[1]) | |
lib.mkpath | |
(lib + 'dependencies.rb').open("w") do |file| | |
file.write LOADER | |
end | |
else | |
vendor = Pathname.new("vendor") | |
vendor.mkpath | |
if File.exist?('.git') ## already using git? | |
system("git add vendor") | |
system("git submodule add git://github.com/#{ARGV[0]}.git vendor/#{ARGV[0]}") | |
else | |
Dir.chdir(vendor.realpath) | |
system("git clone git://github.com/#{ARGV[0]}.git #{ARGV[0]}") | |
if ARGV[1] | |
Dir.chdir(ARGV[0]) | |
system("git checkout #{ARGV[1]}") | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment