Skip to content

Commit

Permalink
Avoid removing files not ended in .rb
Browse files Browse the repository at this point in the history
  • Loading branch information
pacop committed May 16, 2019
1 parent 4b1d45a commit 90b21e3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/warbler/task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ def define_compiled_task
task "compiled" do
jar.compile(config)
task @name do
extensions = config.compiled_ruby_files&.map { |f| File.extname(f) }&.uniq || ['.rb']
regex_extensions = extensions.map { |extension| extension.sub('.', '\.') }.join('|')
rm_f config.compiled_ruby_files.map {|f| f.sub(/#{regex_extensions}$/, '.class') }
rm_f config.compiled_ruby_files.map {|f| f.sub(/\.rb$/, '.class') }
end
end
Expand Down
8 changes: 8 additions & 0 deletions spec/warbler/task_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
config.gems = ["rake"]
config.webserver = "test"
config.webxml.jruby.max.runtimes = 5

config.compiled_ruby_files = FileList['**/*.rb', '**/.rake']
end
end

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

it "should not delete another extensions but .class files after finishing the jar" do
config.features << "compiled"
silence { run_task "warble" }
File.exist?('lib/tasks/utils.rake').should be true
end

context "where symlinks are available" do
begin
FileUtils.ln_s "README.txt", "r.txt.symlink", :verbose => false
Expand Down

0 comments on commit 90b21e3

Please sign in to comment.