diff options
author | Gannon McGibbon <gannon.mcgibbon@gmail.com> | 2018-11-07 18:12:17 -0500 |
---|---|---|
committer | Gannon McGibbon <gannon.mcgibbon@gmail.com> | 2018-11-09 14:48:15 -0500 |
commit | cffbf73a4761816d894a49fbec7f070f27ebbff4 (patch) | |
tree | c9fa727994372b1bd36d67d11b80318948f530ce /railties/lib/rails/paths.rb | |
parent | e0f82a0fb3b46b63fc4a9f668defdba31b6d8b36 (diff) | |
download | rails-cffbf73a4761816d894a49fbec7f070f27ebbff4.tar.gz rails-cffbf73a4761816d894a49fbec7f070f27ebbff4.tar.bz2 rails-cffbf73a4761816d894a49fbec7f070f27ebbff4.zip |
Remove asset paths from eager_load_paths and autoload_paths
Remove `app/assets` and `app/javascript` from `eager_load_paths`
and `autoload_paths`.
Diffstat (limited to 'railties/lib/rails/paths.rb')
-rw-r--r-- | railties/lib/rails/paths.rb | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/railties/lib/rails/paths.rb b/railties/lib/rails/paths.rb index 87222563fd..8367ac8980 100644 --- a/railties/lib/rails/paths.rb +++ b/railties/lib/rails/paths.rb @@ -113,10 +113,11 @@ module Rails attr_accessor :glob def initialize(root, current, paths, options = {}) - @paths = paths - @current = current - @root = root - @glob = options[:glob] + @paths = paths + @current = current + @root = root + @glob = options[:glob] + @exclude = options[:exclude] options[:autoload_once] ? autoload_once! : skip_autoload_once! options[:eager_load] ? eager_load! : skip_eager_load! @@ -189,13 +190,11 @@ module Rails raise "You need to set a path root" unless @root.path result = [] - each do |p| - path = File.expand_path(p, @root.path) + each do |path| + path = File.expand_path(path, @root.path) if @glob && File.directory?(path) - Dir.chdir(path) do - result.concat(Dir.glob(@glob).map { |file| File.join path, file }.sort) - end + result.concat files_in(path) else result << path end @@ -222,6 +221,17 @@ module Rails end alias to_a expanded + + private + + def files_in(path) + Dir.chdir(path) do + files = Dir.glob(@glob) + files -= @exclude if @exclude + files.map! { |file| File.join(path, file) } + files.sort + end + end end end end |