Skip to content

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 pacop force-pushed the fix/remove-not-rb branch from 90b21e3 to de4d87d Compare May 16, 2019 11:56
@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

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/

@chadlwilson chadlwilson changed the title Avoid removing files not ended in .rb 1.x: Avoid removing files not ended in .rb Oct 12, 2025
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.

2 participants