SNRK-99: bug should be fixed

This commit is contained in:
liubar.pa 2023-05-16 00:22:41 +03:00
parent ac8478678e
commit 44bac3b5ea

View File

@ -7,12 +7,14 @@ import java.nio.file.Path
private val MARKDOWN_PARSER = "snark-document-builder/src/main/nodejs/MarkdownParser.js" private val MARKDOWN_PARSER = "snark-document-builder/src/main/nodejs/MarkdownParser.js"
private val SNARK_PARSER = "snark-document-builder/src/main/python/SnarkParser.py" private val SNARK_PARSER = "snark-document-builder/src/main/python/SnarkParser.py"
public suspend fun parseMd(mdFile: ByteArray): MdAstRoot { public suspend fun parseMd(mdFile: ByteArray, parserPath: String = MARKDOWN_PARSER): MdAstRoot {
return jacksonObjectMapper() val process = ProcessBuilder("node", parserPath, String(mdFile))
.readValue<MdAstRoot>(ProcessBuilder("node", MARKDOWN_PARSER, mdFile.toString()) val result = process
.redirectOutput(ProcessBuilder.Redirect.PIPE) .redirectOutput(ProcessBuilder.Redirect.PIPE)
.redirectError(ProcessBuilder.Redirect.INHERIT) .redirectError(ProcessBuilder.Redirect.INHERIT)
.start().inputStream.bufferedReader().readText()) .start().inputStream.bufferedReader().readText()
return jacksonObjectMapper().readValue<MdAstRoot>(result)
} }
public suspend fun buildDependencyGraphNode(mdFile: ByteArray, path: Path): DependencyGraphNode { public suspend fun buildDependencyGraphNode(mdFile: ByteArray, path: Path): DependencyGraphNode {