Created
June 20, 2014 14:59
-
-
Save jforaker/441c2eaf6ee0be326e96 to your computer and use it in GitHub Desktop.
clone_www.rb :: Clone and build - phonegap
This file contains hidden or 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
#!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