Skip to content

Commit

Permalink
cli: createDirectories
Browse files Browse the repository at this point in the history
  • Loading branch information
ice1000 committed Oct 30, 2023
1 parent 312e0dd commit e98e4da
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cli-console/src/main/java/org/aya/cli/console/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
import org.aya.pretty.printer.PrinterConfig;
import org.aya.tyck.trace.MarkdownTrace;
import org.aya.tyck.trace.Trace;
import org.aya.util.FileUtil;
import org.aya.util.error.SourceFile;
import org.aya.util.error.SourceFileLocator;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import picocli.CommandLine;

import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
Expand Down Expand Up @@ -72,7 +72,7 @@ private int doFakeLiterate(@NotNull FileIO filePath) throws IOException {
// Garbage code
var setup = info.backendOpts(false);
var output = renderOptions.render(RenderOptions.OutputTarget.LaTeX, doc, setup);
if (outputPath != null) Files.writeString(outputPath, output, StandardCharsets.UTF_8);
if (outputPath != null) FileUtil.writeString(outputPath, output);
else System.out.println(output);
return 0;
}
Expand Down
1 change: 1 addition & 0 deletions tools/src/main/java/org/aya/util/FileUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public interface FileUtil {
static void writeString(@NotNull Path path, @NotNull String content) throws IOException {
var parent = path.toAbsolutePath().getParent();
if (parent != null && Files.notExists(parent)) Files.createDirectories(parent);
// No need to set UTF_8 since Java 17
Files.writeString(path, content);
}

Expand Down

0 comments on commit e98e4da

Please sign in to comment.