Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rake Task :generate updated to take a project path #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,18 @@ namespace :styles do

end

desc "Generate a new project at dir=foo"
task :generate do
# Generate the new 'dir' if it's not already created
system "mkdir #{(ENV['dir'])}" unless File.exists?(ENV['dir'])
# NOTE: if using zsh shell, call task as following to have zsh avoid the []
# rake 'generate[~/path/myproject]'
desc "Generate a new project at given path/to/project"
task :generate, [:project_path] do |t, args|
args.with_defaults(:project_path => "demo-serve")
folder = args[:project_path]

# Generate the new 'folder' if it's not already created
system "mkdir #{folder}" unless File.exists?(folder)

# Archive the current HEAD to 'dir'
system "git archive HEAD | (cd #{ENV['dir']} && tar -xvf -)"
# Archive the current HEAD to 'folder'
system "git archive HEAD | (cd #{folder} && tar -xvf -)"

puts "\n *** A new project has been generated at: #{(ENV['dir'])} ***"
puts "\n *** A new project has been generated at: '#{folder}' ***"
end