From c8ab4a1871ba86e533f02857169de40b1fc5e84f Mon Sep 17 00:00:00 2001 From: Matthew Pace Date: Thu, 14 Mar 2024 23:17:48 -0400 Subject: [PATCH] move site and collections console commands to locals (#853) --- .../lib/bridgetown-core/commands/console.rb | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/bridgetown-core/lib/bridgetown-core/commands/console.rb b/bridgetown-core/lib/bridgetown-core/commands/console.rb index bace48fac..544ae547b 100644 --- a/bridgetown-core/lib/bridgetown-core/commands/console.rb +++ b/bridgetown-core/lib/bridgetown-core/commands/console.rb @@ -2,17 +2,11 @@ module Bridgetown module ConsoleMethods - def site - Bridgetown::Current.site - end - - def collections - site.collections - end - def reload! Bridgetown.logger.info "Reloading site..." + site = Bridgetown::Current.site + I18n.reload! # make sure any locale files get read again Bridgetown::Hooks.trigger :site, :pre_reload, site Bridgetown::Hooks.clear_reloadable_hooks @@ -98,7 +92,14 @@ def console # rubocop:disable Metrics IRB::ExtendCommandBundle.include ConsoleMethods IRB.setup(nil) - workspace = IRB::WorkSpace.new + workspace = IRB::WorkSpace.new( + begin + site = Bridgetown::Current.site + collections = site.collections + + binding + end + ) irb = IRB::Irb.new(workspace) IRB.conf[:IRB_RC]&.call(irb.context) IRB.conf[:MAIN_CONTEXT] = irb.context