homebrew-core/Formula/prettier.rb

28 lines
859 B
Ruby

require "language/node"
class Prettier < Formula
desc "Code formatter for JavaScript, CSS, JSON, GraphQL, Markdown, YAML"
homepage "https://prettier.io/"
url "https://registry.npmjs.org/prettier/-/prettier-2.8.0.tgz"
sha256 "58ebc3f39f4f1ca4a284811d379a19e19d456547ba784646d68bd97d7d755929"
license "MIT"
head "https://github.com/prettier/prettier.git", branch: "main"
bottle do
sha256 cellar: :any_skip_relocation, all: "68529b66fd81f8626197a4b1bb774706b13bffda8c607b2aabe6da3e6150978f"
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.js").write("const arr = [1,2];")
output = shell_output("#{bin}/prettier test.js")
assert_equal "const arr = [1, 2];", output.chomp
end
end