From a1e80700625f230478c3351031864ae9f7c7ec71 Mon Sep 17 00:00:00 2001 From: Faizaan Gagan Date: Wed, 12 May 2021 06:33:19 +0530 Subject: [PATCH] FIX: move sprockets customization to monkeypatch --- plugin.rb | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/plugin.rb b/plugin.rb index 253ac110..6f5f203a 100644 --- a/plugin.rb +++ b/plugin.rb @@ -35,18 +35,19 @@ if respond_to?(:register_svg_icon) register_svg_icon "save" end +class ::Sprockets::DirectiveProcessor + def process_require_tree_discourse_directive(path = ".") + raise CustomWizard::SprocketsEmptyPath, "path cannot be empty" if path == "." -add_to_class(::Sprockets::DirectiveProcessor, :process_require_tree_discourse_directive) do |path = "."| - raise CustomWizard::SprocketsEmptyPath, "path cannot be empty" if path == "." + discourse_asset_path = "#{Rails.root}/app/assets/javascripts/" + path = File.expand_path(path, discourse_asset_path) + stat = @environment.stat(path) - discourse_asset_path = "#{Rails.root}/app/assets/javascripts/" - path = File.expand_path(path, discourse_asset_path) - stat = @environment.stat(path) - - if stat && stat.directory? - require_paths(*@environment.stat_sorted_tree_with_dependencies(path)) - else - raise CustomWizard::SprocketsFileNotFound, "#{path} not found in discourse core" + if stat && stat.directory? + require_paths(*@environment.stat_sorted_tree_with_dependencies(path)) + else + raise CustomWizard::SprocketsFileNotFound, "#{path} not found in discourse core" + end end end