diff --git a/Formula/mermaid-cli.rb b/Formula/mermaid-cli.rb new file mode 100644 index 0000000000000..c0019af5332ff --- /dev/null +++ b/Formula/mermaid-cli.rb @@ -0,0 +1,42 @@ +require "language/node" + +class MermaidCli < Formula + desc "Command-line interface (CLI) for mermaid" + homepage "https://github.com/mermaid-js/mermaid-cli" + url "https://registry.npmjs.org/@mermaid-js/mermaid-cli/-/mermaid-cli-8.8.4.tgz" + sha256 "d56089a4e82c0c2bba00397bd7ee73164338da32b8e1c381518242a00e29689b" + license "MIT" + + depends_on "node" + + def install + system "npm", "install", *Language::Node.std_npm_install_args(libexec) + bin.install_symlink Dir["#{libexec}/bin/*"] + end + + test do + (testpath/"test.mmd").write <<~EOS + sequenceDiagram + participant Alice + participant Bob + Alice->>John: Hello John, how are you? + loop Healthcheck + John->>John: Fight against hypochondria + end + Note right of John: Rational thoughts
prevail! + John-->>Alice: Great! + John->>Bob: How about you? + Bob-->>John: Jolly good! + EOS + + (testpath/"puppeteer-config.json").write <<~EOS + { + "args": ["--no-sandbox"] + } + EOS + + system bin/"mmdc", "-p", "puppeteer-config.json", "-i", "#{testpath}/test.mmd", "-o", "#{testpath}/out.svg" + + assert_predicate testpath/"out.svg", :exist? + end +end