summaryrefslogtreecommitdiff
path: root/lib/chef/knife/rehash.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chef/knife/rehash.rb')
-rw-r--r--lib/chef/knife/rehash.rb24
1 files changed, 3 insertions, 21 deletions
diff --git a/lib/chef/knife/rehash.rb b/lib/chef/knife/rehash.rb
index 2d7c0c7700..69ee19229a 100644
--- a/lib/chef/knife/rehash.rb
+++ b/lib/chef/knife/rehash.rb
@@ -34,7 +34,9 @@ class Chef
else
reload_plugins
end
- write_hash(generate_hash)
+
+ ui.msg "Knife subcommands are cached in #{Chef::Knife::SubcommandLoader.plugin_manifest_path}. Delete this file to disable the caching."
+ Chef::Knife::SubcommandLoader.write_hash(Chef::Knife::SubcommandLoader.generate_hash)
end
def reload_plugins
@@ -43,26 +45,6 @@ class Chef
# loaded plugins and `load_commands` shouldn't have an effect.
Chef::Knife.subcommand_loader.load_commands
end
-
- def generate_hash
- output = if Chef::Knife::SubcommandLoader.plugin_manifest?
- Chef::Knife::SubcommandLoader.plugin_manifest
- else
- { Chef::Knife::SubcommandLoader::HashedCommandLoader::KEY => {} }
- end
- output[Chef::Knife::SubcommandLoader::HashedCommandLoader::KEY]["plugins_paths"] = Chef::Knife.subcommand_files
- output[Chef::Knife::SubcommandLoader::HashedCommandLoader::KEY]["plugins_by_category"] = Chef::Knife.subcommands_by_category
- output
- end
-
- def write_hash(data)
- plugin_manifest_dir = File.expand_path("..", Chef::Knife::SubcommandLoader.plugin_manifest_path)
- FileUtils.mkdir_p(plugin_manifest_dir) unless File.directory?(plugin_manifest_dir)
- File.open(Chef::Knife::SubcommandLoader.plugin_manifest_path, "w") do |f|
- f.write(Chef::JSONCompat.to_json_pretty(data))
- ui.msg "Knife subcommands are cached in #{Chef::Knife::SubcommandLoader.plugin_manifest_path}. Delete this file to disable the caching."
- end
- end
end
end
end