From 5c2164cdcc08aef4bacb18cc27071c31b57b0200 Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Wed, 27 Nov 2024 18:15:55 -0600 Subject: [PATCH] add instance method to VersionChecker --- lib/react_on_rails/engine.rb | 4 ++-- lib/react_on_rails/version_checker.rb | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/react_on_rails/engine.rb b/lib/react_on_rails/engine.rb index bfbda255d..f6b684f09 100644 --- a/lib/react_on_rails/engine.rb +++ b/lib/react_on_rails/engine.rb @@ -5,8 +5,8 @@ module ReactOnRails class Engine < ::Rails::Engine config.to_prepare do - if VersionChecker.new(NodePackageVersion.new("package.json")).raise_if_gem_and_node_package_versions_differ && - VersionChecker.new(NodePackageVersion.new("client/package.json")).raise_if_gem_and_node_package_versions_differ + if VersionChecker.instance("package.json").raise_if_gem_and_node_package_versions_differ && + VersionChecker.instance("client/package.json").raise_if_gem_and_node_package_versions_differ Rails.logger.warn("No 'react-on-rails' entry found in 'dependencies' in package.json or client/package.json.") end ReactOnRails::ServerRenderingPool.reset_pool diff --git a/lib/react_on_rails/version_checker.rb b/lib/react_on_rails/version_checker.rb index 800d58557..264acafe6 100644 --- a/lib/react_on_rails/version_checker.rb +++ b/lib/react_on_rails/version_checker.rb @@ -12,6 +12,10 @@ def self.build new(NodePackageVersion.build) end + def self.instance(package_json_path) + new(NodePackageVersion.new(package_json_path)) + end + def initialize(node_package_version) @node_package_version = node_package_version end