mirror of
https://github.com/moparisthebest/android.moparisthebest.org
synced 2024-12-23 16:08:53 -05:00
install: Adds confirmation before overwriting existing source_dir
This commit is contained in:
parent
80f8a609f6
commit
f03c4cdb2a
17
Rakefile
17
Rakefile
@ -27,6 +27,9 @@ server_port = "4000" # port for preview server eg. localhost:4000
|
||||
|
||||
desc "Initial setup for Octopress: copies the default theme into the path of Jekyll's generator. Rake install defaults to rake install[classic] to install a different theme run rake install[some_theme_name]"
|
||||
task :install, :theme do |t, args|
|
||||
if File.directory?(source_dir) || File.directory?("sass")
|
||||
abort("rake aborted!") if ask("A theme is already installed, proceeding will overwrite existing files. Are you sure?", ['y', 'n']) == 'n'
|
||||
end
|
||||
# copy theme into working Jekyll directories
|
||||
theme = args.theme || 'classic'
|
||||
puts "## Copying "+theme+" theme into ./#{source_dir} and ./sass"
|
||||
@ -293,6 +296,20 @@ def ok_failed(condition)
|
||||
end
|
||||
end
|
||||
|
||||
def get_stdin(message)
|
||||
print message
|
||||
STDIN.gets.chomp
|
||||
end
|
||||
|
||||
def ask(message, valid_options)
|
||||
if valid_options
|
||||
answer = get_stdin("#{message} #{valid_options.to_s.gsub(/"/, '').gsub(/, /,'/')} ") while !valid_options.include?(answer)
|
||||
else
|
||||
answer = get_stdin(message)
|
||||
end
|
||||
answer
|
||||
end
|
||||
|
||||
desc "list tasks"
|
||||
task :list do
|
||||
puts "Tasks: #{(Rake::Task.tasks - [Rake::Task[:list]]).join(', ')}"
|
||||
|
Loading…
Reference in New Issue
Block a user