Skip to content

Commit c7aba4f

Browse files
authored
CLI should set :mkdirs option by default (#1241) (#1244)
* CLI should set :mkdirs option by default (#1241) * Simplify test by avoiding use of wildcards
1 parent 616e74a commit c7aba4f

File tree

4 files changed

+29
-0
lines changed

4 files changed

+29
-0
lines changed

CHANGELOG.adoc

+4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ Improvement::
1717

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

20+
Bug Fixes::
21+
22+
* CLI should set :mkdirs option by default (#1241) (@mojavelinux)
23+
2024
== 2.5.10 (2023-06-04)
2125

2226
Improvement::

asciidoctorj-core/src/main/java/org/asciidoctor/jruby/cli/AsciidoctorInvoker.java

+2
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ private void convertInput(Asciidoctor asciidoctor, Options options, List<File> i
160160
return;
161161
}
162162

163+
options.setMkDirs(true);
164+
163165
findInvalidInputFile(inputFiles)
164166
.ifPresent(inputFile -> {
165167
System.err.println("asciidoctor: FAILED: input file(s) '"

asciidoctorj-core/src/test/java/org/asciidoctor/jruby/cli/WhenAsciidoctorIsCalledUsingCli.java

+18
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
import static org.hamcrest.MatcherAssert.assertThat;
2121
import static org.hamcrest.Matchers.containsString;
2222
import static org.hamcrest.core.StringStartsWith.startsWith;
23+
import static org.junit.Assert.assertFalse;
24+
import static org.junit.Assert.assertTrue;
2325

2426
@RunWith(Arquillian.class)
2527
public class WhenAsciidoctorIsCalledUsingCli {
@@ -277,6 +279,22 @@ public void with_absolute_path_file_should_be_rendered() {
277279
expectedFile.delete();
278280
}
279281

282+
@Test
283+
public void should_create_targetdir() {
284+
285+
File inputFile = classpath.getResource("relative/sub/test.adoc");
286+
File srcDir = inputFile.getParentFile().getParentFile(); // points to relative/
287+
File toDir = new File(temporaryFolder.getRoot(), getClass().getSimpleName());
288+
File expectedFile = new File(toDir, "test.html");
289+
assertFalse(toDir.exists());
290+
291+
new AsciidoctorInvoker().invoke("-R", srcDir.getPath(), "-D", toDir.getPath(), srcDir.getAbsolutePath() + "/sub/test.adoc");
292+
// Note that the subdirectory /sub is ignored, other than what asciidoctor does with it.
293+
294+
assertTrue(expectedFile.exists());
295+
expectedFile.delete();
296+
}
297+
280298
private ByteArrayOutputStream redirectStdout() {
281299
ByteArrayOutputStream output = new ByteArrayOutputStream();
282300
System.setOut(new PrintStream(output));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
= Test
2+
3+
== Test
4+
5+
Test

0 commit comments

Comments
 (0)