homebrew-core/Formula/json5.rb

40 lines
1.1 KiB
Ruby

require "language/node"
class Json5 < Formula
desc "JSON enhanced with usability features"
homepage "https://json5.org/"
url "https://github.com/json5/json5/archive/v2.2.2.tar.gz"
sha256 "c7543250ba84832c37e94b658f66621ac0eacd5befe7bf043b4a547dbddebcc0"
license "MIT"
bottle do
sha256 cellar: :any_skip_relocation, all: "473056a228a89fb1075f4449b2e04bf7c7629f71dbbb8a48c55788c390889881"
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
# Example taken from the official README
(testpath/"test.json5").write <<~EOF
{
// comments
unquoted: 'and you can quote me on that',
singleQuotes: 'I can use "double quotes" here',
lineBreaks: "Look, Mom! \
No \\n's!",
hexadecimal: 0xdecaf,
leadingDecimalPoint: .8675309, andTrailing: 8675309.,
positiveSign: +1,
trailingComma: 'in objects', andIn: ['arrays',],
"backwardsCompatible": "with JSON",
}
EOF
system bin/"json5", "--validate", "test.json5"
end
end