diff --git a/app/assets/javascripts/admin.js.erb b/app/assets/javascripts/admin.js.erb index 41f0315debb..dda57561778 100644 --- a/app/assets/javascripts/admin.js.erb +++ b/app/assets/javascripts/admin.js.erb @@ -3,10 +3,10 @@ require_asset("main_include_admin.js") DiscoursePluginRegistry.admin_javascripts.each { |js| require_asset(js) } -DiscoursePluginRegistry.each_globbed_asset(admin: true) do |f, ext| +DiscoursePluginRegistry.each_globbed_asset(admin: true) do |f| if File.directory?(f) depend_on(f) - elsif f.to_s.end_with?(".#{ext}") + else require_asset(f) end end diff --git a/app/assets/javascripts/discourse/tests/plugin_tests.js.erb b/app/assets/javascripts/discourse/tests/plugin_tests.js.erb index 5709a19399b..0bb267961df 100644 --- a/app/assets/javascripts/discourse/tests/plugin_tests.js.erb +++ b/app/assets/javascripts/discourse/tests/plugin_tests.js.erb @@ -1,10 +1,10 @@ <% DiscoursePluginRegistry.javascripts.each { |js| require_asset(js) } DiscoursePluginRegistry.handlebars.each { |hb| require_asset(hb) } - DiscoursePluginRegistry.each_globbed_asset do |f, ext| + DiscoursePluginRegistry.each_globbed_asset do |f| if File.directory?(f) depend_on(f) - elsif f.to_s.end_with?(".#{ext}") + else require_asset(f) end end diff --git a/lib/discourse_plugin_registry.rb b/lib/discourse_plugin_registry.rb index 39e00ca3a6e..890165a3158 100644 --- a/lib/discourse_plugin_registry.rb +++ b/lib/discourse_plugin_registry.rb @@ -131,8 +131,8 @@ class DiscoursePluginRegistry next if each_options[:admin] end - Dir.glob("#{root}/**/*") do |f| - yield f, ext + Dir.glob("#{root}/**/*.#{ext}") do |f| + yield f end end end diff --git a/lib/plugin/instance.rb b/lib/plugin/instance.rb index 3471c385050..f449a19593e 100644 --- a/lib/plugin/instance.rb +++ b/lib/plugin/instance.rb @@ -588,11 +588,13 @@ class Plugin::Instance # Automatically include all ES6 JS and hbs files root_path = "#{root_dir_name}/assets/javascripts" + DiscoursePluginRegistry.register_glob(root_path, 'js') if transpile_js DiscoursePluginRegistry.register_glob(root_path, 'js.es6') DiscoursePluginRegistry.register_glob(root_path, 'hbs') DiscoursePluginRegistry.register_glob(root_path, 'hbr') admin_path = "#{root_dir_name}/admin/assets/javascripts" + DiscoursePluginRegistry.register_glob(admin_path, 'js', admin: true) if transpile_js DiscoursePluginRegistry.register_glob(admin_path, 'js.es6', admin: true) DiscoursePluginRegistry.register_glob(admin_path, 'hbs', admin: true) DiscoursePluginRegistry.register_glob(admin_path, 'hbr', admin: true)