Skip to content

Instantly share code, notes, and snippets.

@jforaker
Created June 20, 2014 14:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jforaker/441c2eaf6ee0be326e96 to your computer and use it in GitHub Desktop.
Save jforaker/441c2eaf6ee0be326e96 to your computer and use it in GitHub Desktop.
clone_www.rb :: Clone and build - phonegap
#!env ruby
require 'optparse'
require 'yaml'
DESTINATION_DIRECTORY = './www'
options = {}
OptionParser.new do |opts|
opts.banner = "Usage: clone_www.rb [options]"
opts.on('-s', '--source DIRECTORY', 'Source directory (e.g. ~/PATH/TO/SOMETHING/)') { |v|
options[:source_directory] = v }
opts.on('-f', '--force', 'Force removal of existing directory') { |v| options[:force] = true }
opts.on('-e', '--emulate', 'Run in iOS simulator (requires build)') { |v| options[:emulate] = true }
opts.on('-n', '--no-build', 'Do not build the project') { |v| options[:no_build] = true }
end.parse!
raise "Must specify a source directory via --source" unless options[:source_directory]
commands = []
commands << "rm -r#{(options[:force]) ? 'f' : ''} #{DESTINATION_DIRECTORY}"
commands << "mkdir #{DESTINATION_DIRECTORY}"
commands << "cp -R #{options[:source_directory]}/* #{DESTINATION_DIRECTORY}/"
commands << "./cordova/build" unless options[:no_build]
commands << "./cordova/emulate" if options[:emulate]
commands.each do |command|
puts `#{command}`
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment