UNPKG

yuml2svg

Version:

UML diagramming tool based on the yUML syntax

29 lines (25 loc) 778 B
import yuml2svg from "yuml2svg"; import { promises as fs } from "fs"; import { dirname, join } from "path"; import { fileURLToPath } from "url"; const __dirname = dirname(fileURLToPath(import.meta.url)); const inputFile = join(__dirname, "snippets.json"); export default fs .readFile(inputFile) .then(JSON.parse) .then(Object.entries) .then(snippets => Promise.all( snippets.map(([name, { body }]) => yuml2svg(body.join("\n")) .then(svg => fs.writeFile(join(__dirname, name + ".svg"), svg)) .then(() => Promise.resolve(`${name} example diagram generated successfully`) ) .catch(e => { e.cause = "snippet: " + name; return Promise.reject(e); }) ) ) );