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.1.tgz"
sha256 "e70f531d8744ae7773dbaaf7a35138638c35fda1a853cafa38f5d2ffa51aba9c"
license "MIT"
head "https://github.com/prettier/prettier.git", branch: "main"
bottle do
sha256 cellar: :any_skip_relocation, all: "dbc21dfcb0688ae42e6cad545b537806b8e31be8c4958db95f4de5b9719aa4b8"
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