lib/metanorma/cli/collection.rb in metanorma-cli-1.6.2 vs lib/metanorma/cli/collection.rb in metanorma-cli-1.6.3.pre

- old
+ new

@@ -4,10 +4,11 @@ module Cli class Collection def initialize(file, options) @file = file @options = Cli.with_indifferent_access(options) + @output_dir = @options.delete(:output_dir) @compile_options = @options.delete(:compile) end def self.render(filename, options = {}) new(filename, options).render @@ -31,13 +32,23 @@ end def collection_options @collection_options ||= { compile: @compile_options, + output_folder: build_output_folder, coverpage: options.fetch(:coverpage, nil), - output_folder: options.fetch(:output_folder, source_folder), format: collection_output_formats(options.fetch(:format, "")), } + end + + def build_output_folder + output_folder = options.fetch(:output_folder, nil) + + if output_folder && @output_dir + @output_dir.join(output_folder).to_s + else + output_folder || source_folder + end end def collection_output_formats(formats) if formats.is_a?(String) formats = formats.split(",")