Skip to content

Commit 556eb31

Browse files
authored
Merge pull request #136 from stewartmckee/adding-force-delete-to-erb2haml
Adding force delete to erb2haml
2 parents 3474b2e + b598f6d commit 556eb31

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,13 @@ If you already have .haml files for one or more of the .erb files, the rake task
3737
replacing these .haml files or leaving them in place.
3838

3939
Once the task is complete, you will have the option of deleting the original .erb files. Unless you are under
40-
version control, it is recommended that you decline this option.
40+
version control, it is recommended that you decline this option. If you are running in a script, you can use
41+
an environment variable to answer this question.
42+
43+
$ HAML_RAILS_DELETE_ERB=true rake haml:erb2haml
44+
45+
Running the above will not prompt for the question and will delete the original .erb files. Setting this value to
46+
false will also not prompt, however, will leave the .erb files intact.
4147

4248
### Older versions of Rails
4349

lib/tasks/erb2haml.rake

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,12 @@ namespace :haml do
5858

5959
puts '-'*80
6060
begin
61-
puts 'Would you like to delete the original .erb files? (This is not recommended unless you are under version control.) (y/n)'
62-
should_delete = STDIN.gets.chomp.downcase[0]
61+
if ENV.has_key?("HAML_RAILS_DELETE_ERB")
62+
should_delete = ENV["HAML_RAILS_DELETE_ERB"] == "true" ? "y" : "n"
63+
else
64+
puts 'Would you like to delete the original .erb files? (This is not recommended unless you are under version control.) (y/n)'
65+
should_delete = STDIN.gets.chomp.downcase[0]
66+
end
6367
end until ['y', 'n'].include?(should_delete)
6468

6569
if should_delete == 'y'

0 commit comments

Comments
 (0)