Last active
August 29, 2015 14:16
-
-
Save kimmellj/cf928b5f0ba0847b11a5 to your computer and use it in GitHub Desktop.
SiteGenesis Copy Command
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/ruby | |
# Parameters for doing the copy | |
#destCart = ARGV[0] | |
#baseFile = ARGV[1] | |
destCart = "./cartridges/some_cartridge" | |
baseFile = ARGV[0] | |
# Get the index of the cartridge directory so we can replace the begining | |
# with our desitnation cartridge | |
loc = baseFile.index('cartridge/') | |
# Parse out the necessary portion and combine it with our destination cartridge | |
baseFilePart = baseFile[loc, baseFile.length] | |
destFile = "#{destCart}#{baseFilePart}" | |
# We need just the base directory for the destination | |
# so we can create the directory. We do this by splitting the | |
# path into parts, removing the file name and then recombining | |
dir = destFile.split('/') | |
dir.pop() | |
dir = dir.join('/') | |
# Execute the shell commands | |
`mkdir -p #{dir}` | |
`cp #{baseFile} #{destFile}` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment