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

Avoid removing files not ended in .rb #452

Open
wants to merge 1 commit into
base: 1.x-dev
Choose a base branch
from

Conversation

pacop
Copy link

@pacop pacop commented May 16, 2019

When the option compiled_ruby_files is personalized to use different extensions, for instance, .rake files. They are removed each time warble is called.

Problem was in lib/warbler/task.rb where every file not ended in .rb were being removed.

@pacop
Copy link
Author

pacop commented May 16, 2019

I was not able to pass specs, neither in travis nor my pc. Force-pushed to try again, but it was unsuccessful

@@ -108,7 +108,9 @@ def define_compiled_task
task "compiled" do
jar.compile(config)
task @name do
rm_f config.compiled_ruby_files.map {|f| f.sub(/\.rb$/, '.class') }
extensions = config.compiled_ruby_files&.map { |f| File.extname(f) }&.uniq || ['.rb']
regex_extensions = extensions.map { |extension| extension.sub('.', '\.') }.join('|')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RegExp.union is pretty great:

extensions = Pathname.glob("config/**/*").map(&:extname).uniq
# [".pem", ".rb", ".yml", ".ignore", "", ".md", ".markdown", ".json"]
Regexp.union(extensions)
# /\.pem|\.rb|\.yml|\.ignore||\.md|\.markdown|\.json/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants