From 44bac3b5ea8b5414ea67daf62b45569d68863b56 Mon Sep 17 00:00:00 2001 From: "liubar.pa" Date: Tue, 16 May 2023 00:22:41 +0300 Subject: [PATCH] SNRK-99: bug should be fixed --- snark-document-builder/src/main/kotlin/MdParser.kt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/snark-document-builder/src/main/kotlin/MdParser.kt b/snark-document-builder/src/main/kotlin/MdParser.kt index d502d41..0091cd5 100644 --- a/snark-document-builder/src/main/kotlin/MdParser.kt +++ b/snark-document-builder/src/main/kotlin/MdParser.kt @@ -7,12 +7,14 @@ import java.nio.file.Path private val MARKDOWN_PARSER = "snark-document-builder/src/main/nodejs/MarkdownParser.js" private val SNARK_PARSER = "snark-document-builder/src/main/python/SnarkParser.py" -public suspend fun parseMd(mdFile: ByteArray): MdAstRoot { - return jacksonObjectMapper() - .readValue(ProcessBuilder("node", MARKDOWN_PARSER, mdFile.toString()) +public suspend fun parseMd(mdFile: ByteArray, parserPath: String = MARKDOWN_PARSER): MdAstRoot { + val process = ProcessBuilder("node", parserPath, String(mdFile)) + val result = process .redirectOutput(ProcessBuilder.Redirect.PIPE) .redirectError(ProcessBuilder.Redirect.INHERIT) - .start().inputStream.bufferedReader().readText()) + .start().inputStream.bufferedReader().readText() + + return jacksonObjectMapper().readValue(result) } public suspend fun buildDependencyGraphNode(mdFile: ByteArray, path: Path): DependencyGraphNode {