mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-27 02:04:33 +08:00
add an initializer that creates symlinks to react components in core [fixes SCI-1902]
This commit is contained in:
parent
34a50bf010
commit
0bfa92046d
1 changed files with 16 additions and 0 deletions
16
config/initializers/addon_loader.rb
Normal file
16
config/initializers/addon_loader.rb
Normal file
|
@ -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
|
Loading…
Reference in a new issue