From 96e971f2006330f44ada0c45d5e5a61bbfb9a867 Mon Sep 17 00:00:00 2001 From: bohung Date: Thu, 8 Sep 2022 20:10:19 +0800 Subject: [PATCH] Fix deprecated for ruby 2.7. --- archive.gemspec | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/archive.gemspec b/archive.gemspec index 729ed4b..6803609 100644 --- a/archive.gemspec +++ b/archive.gemspec @@ -6,6 +6,20 @@ require 'json' bundle_update_flag = ARGV[0]=='update' || ARGV[0]=='install' if bundle_update_flag env_pwd = ENV['PWD'] + begin + require ::File.expand_path('app/helpers/bundler_helper.rb', env_pwd) + extend BundlerHelper + rescue LoadError + def bundler_with_clean_env + if block_given? + if Bundler.respond_to?(:with_unbundled_env) + Bundler.with_unbundled_env(&Proc.new) + else + Bundler.with_clean_env(&Proc.new) + end + end + end + end app_path = File.expand_path(__dir__) template_path = env_pwd + '/app/templates' all_template = Dir.glob(template_path+'/*/') @@ -116,7 +130,7 @@ if bundle_update_flag if flags.select{|flag| flag }.count != 0 flags.each_with_index do |flag,i| if flag - Bundler.with_clean_env{%x[cp -f #{app_path}/modules/archive/#{check_files[i]} #{folder}modules/archive/#{check_files[i]}]} + bundler_with_clean_env{%x[cp -f #{app_path}/modules/archive/#{check_files[i]} #{folder}modules/archive/#{check_files[i]}]} end end begin @@ -127,9 +141,9 @@ if bundle_update_flag File.open(info_json_file,"w+"){|f| f.write(info_json)} end force_update_files.each do |update_file| - Bundler.with_clean_env{%x[cp -f #{app_path}/modules/archive/#{update_file} #{folder}modules/archive/#{update_file}]} + bundler_with_clean_env{%x[cp -f #{app_path}/modules/archive/#{update_file} #{folder}modules/archive/#{update_file}]} end - Bundler.with_clean_env{%x[cp -rn #{app_path}/modules/archive/thumbs/* #{folder}modules/archive/thumbs/.]} + bundler_with_clean_env{%x[cp -rn #{app_path}/modules/archive/thumbs/* #{folder}modules/archive/thumbs/.]} rescue puts "There has some error when updating archive index page." end