Skip to content

Commit 90b21e3

Browse files
committed
Avoid removing files not ended in .rb
1 parent 4b1d45a commit 90b21e3

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

lib/warbler/task.rb

+3
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ def define_compiled_task
108108
task "compiled" do
109109
jar.compile(config)
110110
task @name do
111+
extensions = config.compiled_ruby_files&.map { |f| File.extname(f) }&.uniq || ['.rb']
112+
regex_extensions = extensions.map { |extension| extension.sub('.', '\.') }.join('|')
113+
rm_f config.compiled_ruby_files.map {|f| f.sub(/#{regex_extensions}$/, '.class') }
111114
rm_f config.compiled_ruby_files.map {|f| f.sub(/\.rb$/, '.class') }
112115
end
113116
end

spec/warbler/task_spec.rb

+8
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
config.gems = ["rake"]
1919
config.webserver = "test"
2020
config.webxml.jruby.max.runtimes = 5
21+
22+
config.compiled_ruby_files = FileList['**/*.rb', '**/.rake']
2123
end
2224
end
2325

@@ -150,6 +152,12 @@ def run_task(t)
150152
File.exist?('app/helpers/application_helper.class').should be false
151153
end
152154

155+
it "should not delete another extensions but .class files after finishing the jar" do
156+
config.features << "compiled"
157+
silence { run_task "warble" }
158+
File.exist?('lib/tasks/utils.rake').should be true
159+
end
160+
153161
context "where symlinks are available" do
154162
begin
155163
FileUtils.ln_s "README.txt", "r.txt.symlink", :verbose => false

0 commit comments

Comments
 (0)