From 0bfa92046d66aa0a61a318188e19be74b6aa40ac Mon Sep 17 00:00:00 2001 From: zmagod Date: Fri, 12 Jan 2018 17:14:27 +0100 Subject: [PATCH] add an initializer that creates symlinks to react components in core [fixes SCI-1902] --- config/initializers/addon_loader.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 config/initializers/addon_loader.rb diff --git a/config/initializers/addon_loader.rb b/config/initializers/addon_loader.rb new file mode 100644 index 000000000..8be3150ba --- /dev/null +++ b/config/initializers/addon_loader.rb @@ -0,0 +1,16 @@ +# This code fetch the components from the addons but only in the root of the +# addon/**/client folder. + +TARGET_ROOT = "#{Dir.pwd}/app/javascript/src/react-hijack/addons".freeze + +FileUtils.rm_f Dir.glob("#{TARGET_ROOT}/*") +Dir.foreach('addons/') do |path| + addons_client_root = "addons/#{path}/client" + + next unless Dir.exist? addons_client_root + all_files = Dir.glob("#{addons_client_root}/*\.*") + all_files.each do |component| + new_path = component.gsub("#{addons_client_root}/", '') + File.symlink("#{Dir.pwd}/#{component}", "#{TARGET_ROOT}/#{new_path}") + end +end