2020-01-31 21:14:04 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
##
|
|
|
|
# Helper methods for both Gem::Installer and Gem::Uninstaller
|
|
|
|
|
|
|
|
module Gem::InstallerUninstallerUtils
|
|
|
|
|
2020-03-24 02:39:24 -04:00
|
|
|
def regenerate_plugins_for(spec, plugins_dir)
|
2021-02-01 10:17:16 -05:00
|
|
|
plugins = spec.plugins
|
|
|
|
return if plugins.empty?
|
|
|
|
|
|
|
|
require "pathname"
|
|
|
|
|
2020-01-31 21:14:04 -05:00
|
|
|
spec.plugins.each do |plugin|
|
2020-03-24 02:39:24 -04:00
|
|
|
plugin_script_path = File.join plugins_dir, "#{spec.name}_plugin#{File.extname(plugin)}"
|
2020-01-31 21:14:04 -05:00
|
|
|
|
|
|
|
File.open plugin_script_path, "wb" do |file|
|
2021-02-01 10:17:16 -05:00
|
|
|
file.puts "require_relative '#{Pathname.new(plugin).relative_path_from(Pathname.new(plugins_dir))}'"
|
2020-01-31 21:14:04 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
verbose plugin_script_path
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-03-24 02:39:24 -04: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-01-31 21:14:04 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|