If I wanted to get all of the CSS and JavaScript files
Dir.glob("dir/**/*.{css,js})
gives me stuff I don't want if there's a folder named stupidfolder.js
. I would just change the name of the folder, but I can't.
It may be an exaggeration for your problem, but rake
defines a class FileList
. You could replace Dir.glob
with this class:
require 'rake'
filelist = FileList.new("dir/**/*.{css,js}")
filelist.exclude('**/stupidfolder.js')
filelist.each do |file|
#...
end
You can't do that with Dir.glob
. You have to reject those entries explicitly.
only_files = Dir.glob('*').reject do |path|
File.directory?(path)
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With