mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-10 23:25:31 +08:00
fix(addon_loader): make symlink to target addon/client
Signed-off-by: zmagod <zmago_devetak@yahoo.com>
This commit is contained in:
parent
b64b71f9eb
commit
fc5daabb73
1 changed files with 3 additions and 8 deletions
|
@ -1,7 +1,7 @@
|
||||||
# This code fetch the components from the addons but only in the root of the
|
# This code fetch the components from the addons but only in the root of the
|
||||||
# addon/**/client folder.
|
# addon/**/client folder.
|
||||||
|
|
||||||
TARGET_ROOT = "#{Dir.pwd}/app/javascript/src/react-hijack/addons".freeze
|
TARGET_ROOT = "#{Dir.pwd}/app/javascript/src/componentLoader/components".freeze
|
||||||
|
|
||||||
begin
|
begin
|
||||||
# clear previous build
|
# clear previous build
|
||||||
|
@ -10,16 +10,11 @@ FileUtils.rm_f Dir.glob("#{TARGET_ROOT}/*")
|
||||||
Dir.foreach('addons/') do |path|
|
Dir.foreach('addons/') do |path|
|
||||||
addons_client_root = "addons/#{path}/client"
|
addons_client_root = "addons/#{path}/client"
|
||||||
next unless Dir.exist? addons_client_root
|
next unless Dir.exist? addons_client_root
|
||||||
all_files = Dir.glob("#{addons_client_root}/*\.*")
|
File.symlink("#{Dir.pwd}/#{addons_client_root}", "#{TARGET_ROOT}/#{path}")
|
||||||
all_files.each do |component|
|
|
||||||
new_path = component.gsub("#{addons_client_root}/", '')
|
|
||||||
File.symlink("#{Dir.pwd}/#{component}", "#{TARGET_ROOT}/#{new_path}")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
# handles error on the platforms that does not support symlink
|
# handles error on the platforms that does not support symlink
|
||||||
# http://ruby-doc.org/core-2.2.0/File.html#symlink-method
|
# http://ruby-doc.org/core-2.2.0/File.html#symlink-method
|
||||||
rescue NotImplemented => error
|
rescue
|
||||||
puts '[sciNote] Unable to load React components from addons!'
|
puts '[sciNote] Unable to load React components from addons!'
|
||||||
puts '[sciNote] Your system does not support symlink!'
|
puts '[sciNote] Your system does not support symlink!'
|
||||||
puts "[sciNote] #{error.message}"
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue