Created
July 31, 2013 22:04
-
-
Save rachelbaker/6126595 to your computer and use it in GitHub Desktop.
WordPress project setup script
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 | |
# newproj.rb | |
# | |
# Initializes new WordPress projects. | |
# Creates new projects for each passed parameter. | |
# | |
# value - The String representing the project name | |
# | |
# Examples | |
# | |
# ./newproj.rb projectname | |
# # => 'ls -ga projectname' | |
# | |
# Creates empty git repository. | |
# Pulls the WordPress Skeleton repository | |
# Updates and initializes the WordPress submodule | |
# | |
ARGV.each do |value| | |
system `git init #{value}` | |
# change to the new project directory to continue | |
Dir.chdir(value) do | |
system `git pull https://github.com/markjaquith/WordPress-Skeleton.git` | |
# update the WordPress core submodule | |
system "git submodule update" | |
system "git submodule foreach git pull origin master" | |
submodules = `git status | grep "modified.*\(new commits\)" | awk '{print $3}'`.split("\n").map(&:strip) | |
# commit submodule changes to repo | |
if submodules.any? | |
puts "Updating #{submodules.size} submodule(s)..." | |
submodules.each { |name| system "git add #{name}" } | |
commit_message = "Updating #{submodules.size} submodule(s):\n" | |
commit_message << submodules.map { |name| "* #{name}" }.join("\n") | |
system "git commit -m '#{commit_message}'" | |
else | |
puts "No submodules to update" | |
end | |
puts `ls -ga` | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment