From ed44762ff2c380cab76609de44bd0fdd189fd74c Mon Sep 17 00:00:00 2001 From: zmagod Date: Mon, 15 Jan 2018 08:44:59 +0100 Subject: [PATCH] adds rescue --- config/initializers/addon_loader.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/config/initializers/addon_loader.rb b/config/initializers/addon_loader.rb index 8be3150ba..b322fe1e2 100644 --- a/config/initializers/addon_loader.rb +++ b/config/initializers/addon_loader.rb @@ -3,10 +3,12 @@ TARGET_ROOT = "#{Dir.pwd}/app/javascript/src/react-hijack/addons".freeze +begin +# clear previous build 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| @@ -14,3 +16,10 @@ Dir.foreach('addons/') do |path| File.symlink("#{Dir.pwd}/#{component}", "#{TARGET_ROOT}/#{new_path}") end end +# handles error on the platforms that does not support symlink +# http://ruby-doc.org/core-2.2.0/File.html#symlink-method +rescue NotImplemented => error + puts '[sciNote] Unable to load React components from addons!' + puts '[sciNote] Your system does not support symlink!' + puts "[sciNote] #{error.message}" +end