diff options
| author | Dan Allen <dan.j.allen@gmail.com> | 2020-10-16 23:55:37 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-10-16 23:55:37 -0600 |
| commit | df461f9510cdbe9afd392a6cb97d97c07ebdf477 (patch) | |
| tree | 99e5a3680e3aa03710529b9bd540211f72b27c4c | |
| parent | a516e684d5de1e9835ce7563c99c934e43b902bd (diff) | |
resolves #3778 fix resolved value of :to_dir when both :to_file and :to_dir options are set to absolute paths (PR #3781)
| -rw-r--r-- | CHANGELOG.adoc | 1 | ||||
| -rw-r--r-- | lib/asciidoctor/convert.rb | 2 | ||||
| -rw-r--r-- | test/api_test.rb | 16 |
3 files changed, 18 insertions, 1 deletions
diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 0a56046a..d1019d73 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -42,6 +42,7 @@ Bug Fixes:: * Compute highlight line ranges on source block relative to value of start attribute (#3519) (*@mogztter*) * Prevent collapsible block from incrementing example number by assigning an empty caption (#3639) * Use custom init function for highlight.js to select the correct `code` elements (#3761) + * Fix resolved value of :to_dir when both :to_file and :to_dir options are set to absolute paths (#3778) Compliance:: diff --git a/lib/asciidoctor/convert.rb b/lib/asciidoctor/convert.rb index 39feee6b..e8d00783 100644 --- a/lib/asciidoctor/convert.rb +++ b/lib/asciidoctor/convert.rb @@ -63,7 +63,7 @@ module Asciidoctor elsif write_to_target if to_dir if to_file - options[:to_dir] = ::File.dirname ::File.expand_path ::File.join to_dir, to_file + options[:to_dir] = ::File.dirname ::File.expand_path to_file, to_dir else options[:to_dir] = ::File.expand_path to_dir end diff --git a/test/api_test.rb b/test/api_test.rb index f4b8fc26..277fb0fc 100644 --- a/test/api_test.rb +++ b/test/api_test.rb @@ -1320,6 +1320,22 @@ context 'API' do end end + test 'should resolve :to_dir option correctly when both :to_dir and :to_file options are set to an absolute path' do + begin + sample_input_path = fixture_path 'sample.adoc' + sample_output_file = Tempfile.new %w(out- .html) + sample_output_path = sample_output_file.path + sample_output_dir = File.dirname sample_output_path + sample_output_file.close + doc = Asciidoctor.convert_file sample_input_path, to_file: sample_output_path, to_dir: sample_output_dir, safe: :unsafe + assert File.exist? sample_output_path + assert_equal sample_output_path, doc.options[:to_file] + assert_equal sample_output_dir, doc.options[:to_dir] + ensure + sample_output_file.close! + end + end + test 'in_place option is ignored when to_file is specified' do sample_input_path = fixture_path('sample.adoc') sample_output_path = fixture_path('result.html') |
