Fix deprecated for ruby 2.7.

This commit is contained in:
BoHung Chiu 2022-09-08 20:10:19 +08:00
parent b9058ed837
commit 96e971f200
1 changed files with 17 additions and 3 deletions

View File

@ -6,6 +6,20 @@ require 'json'
bundle_update_flag = ARGV[0]=='update' || ARGV[0]=='install' bundle_update_flag = ARGV[0]=='update' || ARGV[0]=='install'
if bundle_update_flag if bundle_update_flag
env_pwd = ENV['PWD'] 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__) app_path = File.expand_path(__dir__)
template_path = env_pwd + '/app/templates' template_path = env_pwd + '/app/templates'
all_template = Dir.glob(template_path+'/*/') all_template = Dir.glob(template_path+'/*/')
@ -116,7 +130,7 @@ if bundle_update_flag
if flags.select{|flag| flag }.count != 0 if flags.select{|flag| flag }.count != 0
flags.each_with_index do |flag,i| flags.each_with_index do |flag,i|
if flag 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
end end
begin begin
@ -127,9 +141,9 @@ if bundle_update_flag
File.open(info_json_file,"w+"){|f| f.write(info_json)} File.open(info_json_file,"w+"){|f| f.write(info_json)}
end end
force_update_files.each do |update_file| 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 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 rescue
puts "There has some error when updating archive index page." puts "There has some error when updating archive index page."
end end