2020-02-01 05:14:04 +03:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
##
|
|
|
|
# Helper methods for both Gem::Installer and Gem::Uninstaller
|
|
|
|
|
|
|
|
module Gem::InstallerUninstallerUtils
|
|
|
|
|
2020-03-24 09:39:24 +03:00
|
|
|
def regenerate_plugins_for(spec, plugins_dir)
|
2021-02-01 18:17:16 +03:00
|
|
|
plugins = spec.plugins
|
|
|
|
return if plugins.empty?
|
|
|
|
|
|
|
|
require 'pathname'
|
|
|
|
|
2020-02-01 05:14:04 +03:00
|
|
|
spec.plugins.each do |plugin|
|
2020-03-24 09:39:24 +03:00
|
|
|
plugin_script_path = File.join plugins_dir, "#{spec.name}_plugin#{File.extname(plugin)}"
|
2020-02-01 05:14:04 +03:00
|
|
|
|
|
|
|
File.open plugin_script_path, 'wb' do |file|
|
2021-02-01 18:17:16 +03:00
|
|
|
file.puts "require_relative '#{Pathname.new(plugin).relative_path_from(Pathname.new(plugins_dir))}'"
|
2020-02-01 05:14:04 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
verbose plugin_script_path
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-03-24 09:39:24 +03:00
|
|
|
def remove_plugins_for(spec, plugins_dir)
|
|
|
|
FileUtils.rm_f Gem::Util.glob_files_in_dir("#{spec.name}#{Gem.plugin_suffix_pattern}", plugins_dir)
|
2020-02-01 05:14:04 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|