diff options
author | Sebastian Celis <sebastian@sebastiancelis.com> | 2017-10-18 16:29:58 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-18 16:29:58 +0300 |
commit | 6f947b076d9e98e945e2ae73d28a156068647925 (patch) | |
tree | 412414f5892f933bdc051644d7ab0662c6a42fec | |
parent | 993557a7e29c419e91e52b4e982a3c3dead62683 (diff) | |
parent | bd37ebf5826304055d7e4e00278b962568276658 (diff) |
Merge pull request #222 from scelis/fix/prefer-formatter-in-args
Always prefer the formatter passed in
-rw-r--r-- | lib/twine/runner.rb | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/twine/runner.rb b/lib/twine/runner.rb index cd21e15..fab6d18 100644 --- a/lib/twine/runner.rb +++ b/lib/twine/runner.rb @@ -69,8 +69,11 @@ module Twine end end - formatter_for_directory = find_formatter { |f| f.can_handle_directory?(@options[:output_path]) } - formatter = formatter_for_format(@options[:format]) || formatter_for_directory + if @options[:format] + formatter = formatter_for_format(@options[:format]) + else + formatter = find_formatter { |f| f.can_handle_directory?(@options[:output_path]) } + end unless formatter raise Twine::Error.new "Could not determine format given the contents of #{@options[:output_path]}" @@ -312,8 +315,11 @@ module Twine end def prepare_read_write(path, lang) - formatter_for_path = find_formatter { |f| f.extension == File.extname(path) } - formatter = formatter_for_format(@options[:format]) || formatter_for_path + if @options[:format] + formatter = formatter_for_format(@options[:format]) + else + formatter = find_formatter { |f| f.extension == File.extname(path) } + end unless formatter raise Twine::Error.new "Unable to determine format of #{path}" |