Skip to content

Commit

Permalink
CLI should set :mkdirs option by default (#1241) (#1244)
Browse files Browse the repository at this point in the history
* CLI should set :mkdirs option by default (#1241)

* Simplify test by avoiding use of wildcards
  • Loading branch information
robertpanzer committed Nov 23, 2023
1 parent 616e74a commit c7aba4f
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ Improvement::

* Upgrade to JRuby 9.4.3.0 (#1235) (@headius)

Bug Fixes::

* CLI should set :mkdirs option by default (#1241) (@mojavelinux)

== 2.5.10 (2023-06-04)

Improvement::
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ private void convertInput(Asciidoctor asciidoctor, Options options, List<File> i
return;
}

options.setMkDirs(true);

findInvalidInputFile(inputFiles)
.ifPresent(inputFile -> {
System.err.println("asciidoctor: FAILED: input file(s) '"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.core.StringStartsWith.startsWith;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

@RunWith(Arquillian.class)
public class WhenAsciidoctorIsCalledUsingCli {
Expand Down Expand Up @@ -277,6 +279,22 @@ public void with_absolute_path_file_should_be_rendered() {
expectedFile.delete();
}

@Test
public void should_create_targetdir() {

File inputFile = classpath.getResource("relative/sub/test.adoc");
File srcDir = inputFile.getParentFile().getParentFile(); // points to relative/
File toDir = new File(temporaryFolder.getRoot(), getClass().getSimpleName());
File expectedFile = new File(toDir, "test.html");
assertFalse(toDir.exists());

new AsciidoctorInvoker().invoke("-R", srcDir.getPath(), "-D", toDir.getPath(), srcDir.getAbsolutePath() + "/sub/test.adoc");
// Note that the subdirectory /sub is ignored, other than what asciidoctor does with it.

assertTrue(expectedFile.exists());
expectedFile.delete();
}

private ByteArrayOutputStream redirectStdout() {
ByteArrayOutputStream output = new ByteArrayOutputStream();
System.setOut(new PrintStream(output));
Expand Down
5 changes: 5 additions & 0 deletions asciidoctorj-core/src/test/resources/relative/sub/test.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
= Test

== Test

Test

0 comments on commit c7aba4f

Please sign in to comment.