Skip to content

Instantly share code, notes, and snippets.

@kimmellj
Last active August 29, 2015 14:16
Show Gist options
  • Save kimmellj/cf928b5f0ba0847b11a5 to your computer and use it in GitHub Desktop.
Save kimmellj/cf928b5f0ba0847b11a5 to your computer and use it in GitHub Desktop.
SiteGenesis Copy Command
#!/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