homebrew-core/Formula/markdownlint-cli2.rb

37 lines
1.1 KiB
Ruby

require "language/node"
class MarkdownlintCli2 < Formula
desc "Fast, flexible, config-based cli for linting Markdown/CommonMark files"
homepage "https://github.com/DavidAnson/markdownlint-cli2"
url "https://registry.npmjs.org/markdownlint-cli2/-/markdownlint-cli2-0.6.0.tgz"
sha256 "44169d57885f86f5fb1f5e8c0bcc599fcfc667b5ee408ab309be52a889297c77"
license "MIT"
bottle do
sha256 cellar: :any_skip_relocation, all: "7181cd1f02f7811976b439b1de0413fb1e4cf458b3a993c4fe7d120d14b391ca"
end
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-bad.md").write <<~EOS
# Header 1
body
EOS
(testpath/"test-good.md").write <<~EOS
# Header 1
body
EOS
assert_match "Summary: 1 error(s)",
shell_output("#{bin}/markdownlint-cli2 :#{testpath}/test-bad.md 2>&1", 1)
assert_match "Summary: 0 error(s)",
shell_output("#{bin}/markdownlint-cli2 :#{testpath}/test-good.md")
end
end