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.2.tgz"
sha256 "0d44d625d412749a71b8ada18da10950cd9b4f10725eca2a7eba28a0f5c3c629"
license "MIT"
head "https://github.com/prettier/prettier.git", branch: "main"
bottle do
sha256 cellar: :any_skip_relocation, all: "4e7449bc27e33d79116ece85be3cb9a25f3a8d5279d924c8b7ae7e753e2d8773"
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