diff --git a/CHANGELOG.md b/CHANGELOG.md index 034fe2b7..e320cd82 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a ## [Unreleased] +## [5.0.1] - 2022-11-10 + +### Changed + +- Fix the plugin parsing on the CLI so that they are respected. + ## [5.0.0] - 2022-11-09 ### Added @@ -450,7 +456,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a - 🎉 Initial release! 🎉 -[unreleased]: https://github.com/ruby-syntax-tree/syntax_tree/compare/v5.0.0...HEAD +[unreleased]: https://github.com/ruby-syntax-tree/syntax_tree/compare/v5.0.1...HEAD +[5.0.1]: https://github.com/ruby-syntax-tree/syntax_tree/compare/v5.0.0...v5.0.1 [5.0.0]: https://github.com/ruby-syntax-tree/syntax_tree/compare/v4.3.0...v5.0.0 [4.3.0]: https://github.com/ruby-syntax-tree/syntax_tree/compare/v4.2.0...v4.3.0 [4.2.0]: https://github.com/ruby-syntax-tree/syntax_tree/compare/v4.1.0...v4.2.0 diff --git a/Gemfile.lock b/Gemfile.lock index d9067ba9..ffbdc5d1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - syntax_tree (5.0.0) + syntax_tree (5.0.1) prettier_print (>= 1.1.0) GEM diff --git a/lib/syntax_tree.rb b/lib/syntax_tree.rb index c2cb3484..418468a9 100644 --- a/lib/syntax_tree.rb +++ b/lib/syntax_tree.rb @@ -40,6 +40,10 @@ module SyntaxTree # optional second argument to ::format. DEFAULT_PRINT_WIDTH = 80 + # This is the default ruby version that we're going to target for formatting. + # It shouldn't really be changed except in very niche circumstances. + DEFAULT_RUBY_VERSION = Formatter::SemanticVersion.new(RUBY_VERSION).freeze + # This is a hook provided so that plugins can register themselves as the # handler for a particular file type. def self.register_handler(extension, handler) diff --git a/lib/syntax_tree/cli.rb b/lib/syntax_tree/cli.rb index 3975df18..392dd627 100644 --- a/lib/syntax_tree/cli.rb +++ b/lib/syntax_tree/cli.rb @@ -377,14 +377,19 @@ class Options :plugins, :print_width, :scripts, - :formatter_options + :target_ruby_version def initialize @ignore_files = [] @plugins = [] @print_width = DEFAULT_PRINT_WIDTH @scripts = [] - @formatter_options = Formatter::Options.new + @target_ruby_version = DEFAULT_RUBY_VERSION + end + + def formatter_options + @formatter_options ||= + Formatter::Options.new(target_ruby_version: target_ruby_version) end def parse(arguments) @@ -430,10 +435,7 @@ def parser # If there is a target ruby version specified on the command line, # parse that out and use it when formatting. opts.on("--target-ruby-version=VERSION") do |version| - @formatter_options = - Formatter::Options.new( - target_ruby_version: Formatter::SemanticVersion.new(version) - ) + @target_ruby_version = Formatter::SemanticVersion.new(version) end end end diff --git a/lib/syntax_tree/version.rb b/lib/syntax_tree/version.rb index 29a413d9..340bbbdf 100644 --- a/lib/syntax_tree/version.rb +++ b/lib/syntax_tree/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module SyntaxTree - VERSION = "5.0.0" + VERSION = "5.0.1" end